Simplify linking
Thanks @mano3m
This commit is contained in:
1 parent
08554889fd
commit
8e9e7b49ea
2 files changed
+18
-16
No files matched your search
@@ -120,10 +120,10 @@ config = [{
|
|||||||
{
|
{
|
||||||
'name': 'file_action',
|
'name': 'file_action',
|
||||||
'label': 'Torrent File Action',
|
'label': 'Torrent File Action',
|
||||||
'default': 'move',
|
'default': 'link',
|
||||||
'type': 'dropdown',
|
'type': 'dropdown',
|
||||||
'values': [('Move', 'move'), ('Copy', 'copy'), ('Hard link', 'hardlink'), ('Move & Sym link', 'move_symlink')],
|
'values': [('Link', 'link'), ('Copy', 'copy'), ('Move', 'move')],
|
||||||
'description': 'Define which kind of file operation you want to use for torrents. Before you start using <a href="http://en.wikipedia.org/wiki/Hard_link">hard links</a> or <a href="http://en.wikipedia.org/wiki/Sym_link">sym links</a>, PLEASE read about their possible drawbacks.',
|
'description': '<strong>Link</strong> or <strong>Copy</strong> after downloading completed (and allow for seeding), or <strong>Move</strong> after seeding completed. Link first tries <a href="http://en.wikipedia.org/wiki/Hard_link">hard link</a>, then <a href="http://en.wikipedia.org/wiki/Sym_link">sym link</a> and falls back to Copy.',
|
||||||
'advanced': True,
|
'advanced': True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Executable → Regular
+15
-13
@@ -548,21 +548,23 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
try:
|
try:
|
||||||
if forcemove:
|
if forcemove:
|
||||||
shutil.move(old, dest)
|
shutil.move(old, dest)
|
||||||
elif self.conf('file_action') == 'hardlink':
|
|
||||||
try:
|
|
||||||
link(old, dest)
|
|
||||||
except:
|
|
||||||
log.error('Couldn\'t hardlink file "%s" to "%s". Copying instead. Error: %s. ', (old, dest, traceback.format_exc()))
|
|
||||||
shutil.copy(old, dest)
|
|
||||||
elif self.conf('file_action') == 'copy':
|
elif self.conf('file_action') == 'copy':
|
||||||
shutil.copy(old, dest)
|
shutil.copy(old, dest)
|
||||||
elif self.conf('file_action') == 'move_symlink':
|
elif self.conf('file_action') == 'link':
|
||||||
shutil.move(old, dest)
|
# First try to hardlink
|
||||||
try:
|
try:
|
||||||
symlink(dest, old)
|
log.debug('Hardlinking file "%s" to "%s"...', (old, dest))
|
||||||
|
link(old, dest)
|
||||||
except:
|
except:
|
||||||
log.error('Couldn\'t symlink file "%s" to "%s". Copying the file back. Error: %s. ', (old, dest, traceback.format_exc()))
|
# Try to simlink next
|
||||||
shutil.copy(dest, old)
|
log.debug('Couldn\'t hardlink file "%s" to "%s". Simlinking instead. Error: %s. ', (old, dest, traceback.format_exc()))
|
||||||
|
shutil.copy(old, dest)
|
||||||
|
try:
|
||||||
|
symlink(dest, old + '.link')
|
||||||
|
os.unlink(old)
|
||||||
|
os.rename(old + '.link', old)
|
||||||
|
except:
|
||||||
|
log.error('Couldn\'t symlink file "%s" to "%s". Copied instead. Error: %s. ', (old, dest, traceback.format_exc()))
|
||||||
else:
|
else:
|
||||||
shutil.move(old, dest)
|
shutil.move(old, dest)
|
||||||
|
|
||||||
@@ -767,10 +769,10 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
for item in scan_items:
|
for item in scan_items:
|
||||||
# Ask the renamer to scan the item
|
# Ask the renamer to scan the item
|
||||||
if item['scan']:
|
if item['scan']:
|
||||||
if item['pause'] and self.conf('file_action') == 'move_symlink':
|
if item['pause'] and self.conf('file_action') == 'link':
|
||||||
fireEvent('download.pause', item = item, pause = True, single = True)
|
fireEvent('download.pause', item = item, pause = True, single = True)
|
||||||
fireEvent('renamer.scan', download_info = item)
|
fireEvent('renamer.scan', download_info = item)
|
||||||
if item['pause'] and self.conf('file_action') == 'move_symlink':
|
if item['pause'] and self.conf('file_action') == 'link':
|
||||||
fireEvent('download.pause', item = item, pause = False, single = True)
|
fireEvent('download.pause', item = item, pause = False, single = True)
|
||||||
if item['process_complete']:
|
if item['process_complete']:
|
||||||
#First make sure the files were succesfully processed
|
#First make sure the files were succesfully processed
|
||||||
|
|||||||
Reference in new issue
Block a user