Skip to content

Commit

Permalink
fs: reflink: try to normalize permissions on any platform
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Dec 6, 2023
1 parent 3a2fd37 commit e78f817
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
9 changes: 2 additions & 7 deletions src/dvc_objects/fs/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import errno
import logging
import os
import sys
from contextlib import suppress
from functools import wraps
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union
Expand Down Expand Up @@ -61,12 +60,8 @@ def _link(

func = getattr(to_fs, link)
func(from_path, to_path)
if (
link == "reflink"
and sys.platform == "darwin"
and isinstance(from_fs, LocalFileSystem)
):
# NOTE: reflink on macos also clones src permissions
if link == "reflink" and isinstance(from_fs, LocalFileSystem):
# NOTE: reflink may or may not clone src permissions
os.chmod(to_path, 0o666 & ~umask)


Expand Down
5 changes: 2 additions & 3 deletions src/dvc_objects/fs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@ def copyfile(

try:
system.reflink(src, dest)
if sys.platform == "darwin":
# NOTE: reflink on macos also clones src permissions
os.chmod(dest, 0o666 & ~umask)
# NOTE: reflink may or may not clone src permissions
os.chmod(dest, 0o666 & ~umask)
return
except OSError:
pass
Expand Down

0 comments on commit e78f817

Please sign in to comment.