-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add log for debugging safe_copy issue during source_packaging #715
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -793,26 +793,52 @@ def safe_copy(src: FileInfo, dst: FileInfo) -> None: | |
:param src: the source FileInfo object | ||
:param dst: the target FileInfo object | ||
""" | ||
e3.log.debug(f"safe_copy - debug : src={src} -> dst={dst}", exc_info=True) | ||
if islink(src): # windows: no cover | ||
e3.log.debug(f"safe_copy - debug : islink : {src}", exc_info=True) | ||
linkto = os.readlink(src.path) | ||
if not islink(dst) or os.readlink(dst.path) != linkto: | ||
if dst.stat is not None: | ||
rm(dst.path, recursive=True, glob=False) | ||
os.symlink(linkto, dst.path) | ||
e3.log.debug( | ||
f"safe_copy - debug copy: islink : src={src} -> dst={dst}", | ||
exc_info=True, | ||
) | ||
copystat(src, dst) | ||
else: | ||
e3.log.debug( | ||
f"safe_copy - debug copy: NOT islink : src={src} -> dst={dst}", | ||
exc_info=True, | ||
) | ||
if isdir(dst): | ||
# dst directory will be replaced by a file having the same | ||
# content as 'src' | ||
e3.log.debug( | ||
f"safe_copy - debug : NOT islink : src={src}, isdir: dst ={dst}", | ||
exc_info=True, | ||
) | ||
rm(dst.path, recursive=True, glob=False) | ||
elif islink(dst): | ||
e3.log.debug( | ||
f"safe_copy - debug : NOT islink : src={src}, islink: dst ={dst}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it's |
||
exc_info=True, | ||
) | ||
# dst symlink will be replaced by a file having the same | ||
# content as 'src' | ||
rm(dst.path, recursive=False, glob=False) | ||
|
||
try: | ||
if dst.basename != src.basename: | ||
e3.log.debug( | ||
f"safe_copy - debug : src:{src} file != dst:{dst} file", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shoule mention the basename |
||
exc_info=True, | ||
) | ||
if dst.stat is not None: | ||
e3.log.debug( | ||
f"safe_copy - debug: dst.stat is not None. dst={dst}", | ||
exc_info=True, | ||
) | ||
# Case in which the destination file exists but does | ||
# not have the same casing. In that case we delete the | ||
# target file and redo a copy. This occurs for example | ||
|
@@ -828,11 +854,24 @@ def safe_copy(src: FileInfo, dst: FileInfo) -> None: | |
with open(dst.path, "wb") as fdst: | ||
shutil.copyfileobj(fsrc, fdst) | ||
except OSError: | ||
e3.log.debug( | ||
f"safe_copy - debug: Got OSError!! src={src}, dst={dst}", | ||
exc_info=True, | ||
) | ||
if dst.stat is not None: | ||
e3.log.debug( | ||
f"safe_copy - debug: OSError: dst.stat != None. dst={dst}", | ||
exc_info=True, | ||
) | ||
rm(dst.path, glob=False) | ||
with open(src.path, "rb") as fsrc: | ||
with open(dst.path, "wb") as fdst: | ||
shutil.copyfileobj(fsrc, fdst) | ||
|
||
e3.log.debug( | ||
f"safe_copy - debug copy: copystat src={src} -> dst={dst}", | ||
exc_info=True, | ||
) | ||
copystat(src, dst) | ||
|
||
def safe_mkdir(src: FileInfo, dst: FileInfo) -> None: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is the same as above.
Better state
isdir
?