Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions fsspec/implementations/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,13 @@ def commit(self):
if self.autocommit:
raise RuntimeError("Can only commit if not already set to autocommit")
shutil.move(self.temp, self.path)
try:
# Get the current umask and set it temporarily to 0o666.
umask = os.umask(0o666)
os.umask(umask)
os.chmod(self.path, 0o666 & ~umask)
except RuntimeError:
pass

def discard(self):
if self.autocommit:
Expand Down
13 changes: 13 additions & 0 deletions fsspec/implementations/tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,19 @@ def test_commit_discard(tmpdir):
assert not fs.exists(tmpdir + "/bfile")


def test_same_permissions_with_and_without_transaction(tmpdir):
tmpdir = str(tmpdir)

with fsspec.open(tmpdir + "/afile", 'wb') as f:
f.write(b'data')

fs, urlpath = fsspec.core.url_to_fs(tmpdir + "/bfile")
with fs.transaction, fs.open(urlpath, 'wb') as f:
f.write(b'data')

assert fs.info(tmpdir + "/afile")["mode"] == fs.info(tmpdir + "/bfile")["mode"]


def test_make_path_posix():
cwd = os.getcwd()
if WIN:
Expand Down