We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d72b1a2 commit bacb08aCopy full SHA for bacb08a
jupyter_server/services/contents/fileio.py
@@ -39,6 +39,12 @@ def copy2_safe(src, dst, log=None):
39
40
like shutil.copy2, but log errors in copystat instead of raising
41
"""
42
+ # if src file is not writable, avoid creating a back-up
43
+ if not os.access(src, os.W_OK):
44
+ if log:
45
+ log.debug("Source file, %s, is not writable", src, exc_info=True)
46
+ raise PermissionError(errno.EACCES, f"File is not writable: {src}")
47
+
48
shutil.copyfile(src, dst)
49
try:
50
shutil.copystat(src, dst)
@@ -52,6 +58,11 @@ async def async_copy2_safe(src, dst, log=None):
52
58
53
59
54
60
61
62
63
64
65
55
66
await run_sync(shutil.copyfile, src, dst)
56
67
57
68
await run_sync(shutil.copystat, src, dst)
0 commit comments