Skip to content
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 Keep link as post processing method #7986

Merged
merged 3 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased

#### New Features
- Add Keep link as post processing method ([7986](https://github.com/pymedusa/Medusa/pull/7986))

#### Improvements
- Add show names with dashes to guessit expected titles ([#7918](https://github.com/pymedusa/Medusa/pull/7918))
Expand Down
17 changes: 14 additions & 3 deletions medusa/post_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,17 @@ def symlink(cur_file_path, new_file_path):
(cur_file_path, new_file_path, e), logger.ERROR)
raise EpisodePostProcessingFailedException('Unable to move and link the files to their new home')

def keeplink(cur_file_path, new_file_path):
self.log(u'Symbolic linking file from {0} to {1}'.format
(cur_file_path, new_file_path), logger.DEBUG)
try:
helpers.symlink(cur_file_path, new_file_path)
helpers.chmod_as_parent(new_file_path)
except (IOError, OSError) as e:
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')

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:
Expand All @@ -522,7 +533,7 @@ def reflink(cur_file_path, new_file_path):
(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, 'reflink': reflink}.get(self.process_method)
action = {'copy': copy, 'move': move, 'hardlink': hardlink, 'symlink': symlink, 'reflink': reflink, 'keeplink': keeplink}.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=associated_files,
Expand Down Expand Up @@ -1229,7 +1240,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', 'reflink']:
if self.process_method in ['copy', 'hardlink', 'move', 'symlink', 'reflink', 'keeplink']:
if not self.process_method == 'hardlink':
if helpers.is_file_locked(self.file_path, False):
raise EpisodePostProcessingFailedException('File is locked for reading')
Expand Down Expand Up @@ -1302,7 +1313,7 @@ def process(self):
self._run_extra_scripts(ep_obj)

if not self.nzb_name and all([app.USE_TORRENTS, app.TORRENT_SEED_LOCATION,
self.process_method in ('hardlink', 'symlink', 'reflink')]):
self.process_method in ('hardlink', 'symlink', 'reflink', 'keeplink')]):
# Store self.info_hash and self.release_name so later we can remove from client if setting is enabled
if self.info_hash:
existing_release_names = app.RECENTLY_POSTPROCESSED.get(self.info_hash, [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ export default {
{ value: 'copy', text: 'Copy' },
{ value: 'move', text: 'Move' },
{ value: 'hardlink', text: 'Hard Link' },
{ value: 'symlink', text: 'Symbolic Link' }
{ value: 'symlink', text: 'Symbolic Link' },
{ value: 'keeplink', text: 'Keep Link' }
],
timezoneOptions: [
{ value: 'local', text: 'Local' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ exports[`ConfigPostProcessing.test.js renders 1`] = `
>
Symbolic Link
</option>
<option
value="keeplink"
>
Keep Link
</option>
</select>

<span>
Expand Down
8 changes: 4 additions & 4 deletions themes-default/slim/views/home_postprocess.mako
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
<td>
<select name="process_method" id="process_method" class="form-control form-control-inline input-sm" >
% if pkgutil.find_loader('reflink') is not None:
<% process_method_text = {'copy': "Copy", 'move': "Move", 'hardlink': "Hard Link", 'symlink' : "Symbolic Link", 'reflink': "Reference Link"} %>
% for cur_action in ('copy', 'move', 'hardlink', 'symlink', 'reflink'):
<% process_method_text = {'copy': "Copy", 'move': "Move", 'hardlink': "Hard Link", 'symlink' : "Symbolic Link", 'reflink': "Reference Link", 'keeplink' : "Keep Link" } %>
% for cur_action in ('copy', 'move', 'hardlink', 'symlink', 'reflink', 'keeplink'):
<option value="${cur_action}" ${'selected="selected"' if app.PROCESS_METHOD == cur_action else ''}>${process_method_text[cur_action]}</option>
% endfor
% else:
<% process_method_text = {'copy': "Copy", 'move': "Move", 'hardlink': "Hard Link", 'symlink' : "Symbolic Link"} %>
% for cur_action in ('copy', 'move', 'hardlink', 'symlink'):
<% process_method_text = {'copy': "Copy", 'move': "Move", 'hardlink': "Hard Link", 'symlink' : "Symbolic Link", 'keeplink' : "Keep Link"} %>
% for cur_action in ('copy', 'move', 'hardlink', 'symlink', 'keeplink'):
<option value="${cur_action}" ${'selected="selected"' if app.PROCESS_METHOD == cur_action else ''}>${process_method_text[cur_action]}</option>
% endfor
% endif
Expand Down
2 changes: 1 addition & 1 deletion themes/dark/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions themes/dark/templates/home_postprocess.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion themes/light/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions themes/light/templates/home_postprocess.mako

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.