Skip to content

Commit

Permalink
remote: local: protect uploaded files (iterative#3858)
Browse files Browse the repository at this point in the history
  • Loading branch information
pared authored May 22, 2020
1 parent 58c9ff0 commit d74358e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dvc/remote/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ def _upload(
copyfile(
from_file, tmp_file, name=name, no_progress_bar=no_progress_bar
)

self.protect(tmp_file)
os.rename(tmp_file, to_info)

def _download(
Expand Down
13 changes: 13 additions & 0 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import errno
import os
import stat

import configobj
import pytest
Expand Down Expand Up @@ -355,3 +356,15 @@ def test_remote_default(dvc):
assert remote_name not in config.get("remote", {})
local_config = dvc.config.load_one("local")
assert local_config["core"]["remote"] == new_name


def test_protect_local_remote(tmp_dir, dvc, setup_remote):
setup_remote(dvc, name="upstream")
(stage,) = tmp_dir.dvc_gen("file", "file content")

dvc.push()
remote = dvc.cloud.get_remote("upstream")
remote_cache_file = remote.checksum_to_path_info(stage.outs[0].checksum)

assert os.path.exists(remote_cache_file)
assert stat.S_IMODE(os.stat(remote_cache_file).st_mode) == 0o444

0 comments on commit d74358e

Please sign in to comment.