-
Notifications
You must be signed in to change notification settings - Fork 276
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
Fix reference linking #4463
Fix reference linking #4463
Changes from 1 commit
514ed25
8aa65c3
c143c34
d8067b7
80a8685
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -433,8 +433,8 @@ def reflink_file(src_file, dest_file): | |
if reflink is None: | ||
raise NotImplementedError() | ||
reflink.reflink(src_file, dest_file) | ||
except reflink.ReflinkImpossibleError as msg: | ||
if msg.args[0] == 'EOPNOTSUPP': | ||
except (reflink.ReflinkImpossibleError, IOError) as msg: | ||
if msg.args is not None and msg.args[0] == 'EOPNOTSUPP': | ||
log.warning( | ||
u'Failed to create reference link of {source} at {destination}.' | ||
u' Error: Filesystem or OS has not implemented reflink. Copying instead', { | ||
|
@@ -443,7 +443,7 @@ def reflink_file(src_file, dest_file): | |
} | ||
) | ||
copy_file(src_file, dest_file) | ||
elif msg.args[0] == 'EXDEV': | ||
elif msg.args is not None and msg.args[0] == 'EXDEV': | ||
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. Same: if isinstance(msg.args, tuple) and msg.args[0] == 'EXDEV': |
||
log.warning( | ||
u'Failed to create reference link of {source} at {destination}.' | ||
u' Error: Can not reflink between two devices. Copying instead', { | ||
|
@@ -471,16 +471,6 @@ def reflink_file(src_file, dest_file): | |
} | ||
) | ||
copy_file(src_file, dest_file) | ||
except IOError as msg: | ||
log.warning( | ||
u'Failed to create reflink of {source} at {destination}.' | ||
u' Error: {error!r}. Copying instead', { | ||
'source': src_file, | ||
'destination': dest_file, | ||
'error': msg, | ||
} | ||
) | ||
copy_file(src_file, dest_file) | ||
|
||
|
||
def make_dirs(path): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -506,10 +506,20 @@ def symlink(cur_file_path, new_file_path): | |
self.log(u'Unable to link file {0} to {1}: {2!r}'.format | ||
(cur_file_path, new_file_path, e), logger.ERROR) | ||
raise EpisodePostProcessingFailedException('Unable to move and link the files to their new home') | ||
|
||
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. @Kriskras99 The build is failing due to the white spaces here. 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. @sharkykh thanks for the pointer |
||
def reflink(cur_file_path, new_file_path): | ||
self.log(u'Reflink file from {0} to {1}'.format(cur_file_path, new_basename), logger.DEBUG) | ||
try: | ||
helpers.reflink_file(cur_file_path, new_file_path) | ||
helpers.chmod_as_parent(new_file_path) | ||
except (IOError, OSError) as e: | ||
self.log(u'Unable to reflink file {0} to {1}: {2!r}'.format | ||
(cur_file_path, new_file_path, e), logger.ERROR) | ||
raise EpisodePostProcessingFailedException('Unable to copy the files to their new home') | ||
|
||
action = {'copy': copy, 'move': move, 'hardlink': hardlink, 'symlink': symlink}.get(self.process_method) | ||
# Subtitle action should be move in case of hardlink|symlink as downloaded subtitle is not part of torrent | ||
subtitle_action = {'copy': copy, 'move': move, 'hardlink': move, 'symlink': move}.get(self.process_method) | ||
action = {'copy': copy, 'move': move, 'hardlink': hardlink, 'symlink': symlink, 'reflink': reflink}.get(self.process_method) | ||
# Subtitle action should be move in case of hardlink|symlink|reflink as downloaded subtitle is not part of torrent | ||
subtitle_action = {'copy': copy, 'move': move, 'hardlink': move, 'symlink': move, 'reflink': move}.get(self.process_method) | ||
self._combined_file_operation(file_path, new_path, new_basename, associated_files, | ||
action=action, subtitle_action=subtitle_action, subtitles=subtitles) | ||
|
||
|
@@ -1222,7 +1232,7 @@ def process(self): | |
|
||
try: | ||
# do the action to the episode and associated files to the show dir | ||
if self.process_method in ['copy', 'hardlink', 'move', 'symlink']: | ||
if self.process_method in ['copy', 'hardlink', 'move', 'symlink', 'reflink']: | ||
if not self.process_method == 'hardlink': | ||
if helpers.is_file_locked(self.file_path, False): | ||
raise EpisodePostProcessingFailedException('File is locked for reading') | ||
|
@@ -1295,7 +1305,7 @@ def process(self): | |
self._run_extra_scripts(ep_obj) | ||
|
||
if not self.nzb_name and all([app.USE_TORRENTS, | ||
app.PROCESS_METHOD in ('hardlink', 'symlink'), | ||
app.PROCESS_METHOD in ('hardlink', 'symlink', 'reflink'), | ||
app.TORRENT_SEED_LOCATION]): | ||
# Store self.info_hash and self.release_name so later we can remove from client if setting is enabled | ||
if self.info_hash: | ||
|
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.
I'd prefer: