Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SiCKRAGE
sickrage
Commits
eca1d42f
Commit
eca1d42f
authored
Nov 11, 2018
by
echel0n
Browse files
Refactored naming convention of misc helper functions.
Added ability to disable stripping of special permissions from files.
parent
63f98ef0
Changes
17
Show whitespace changes
Inline
Side-by-side
changelog.md
View file @
eca1d42f
# Changelog
# Changelog
-
*
fec82ca - 2018-11-11: Cleaned up subtitles code.
-
*
23957a3 - 2018-11-11: Refactored naming convention of misc helper functions. Added ability to disable stripping of special permissions from files.
-
*
63f98ef - 2018-11-11: Cleaned up subtitles code.
-
*
1558dce - 2018-11-10: Fixed issue with displaying language flags in views
-
*
1558dce - 2018-11-10: Fixed issue with displaying language flags in views
-
*
0173a0f - 2018-11-10: Release v9.4.28
-
*
0173a0f - 2018-11-10: Release v9.4.28
-
*
c5ea143 - 2018-11-10: Release v9.4.27
-
*
c5ea143 - 2018-11-10: Release v9.4.27
...
...
sickrage/core/__init__.py
View file @
eca1d42f
...
@@ -204,13 +204,13 @@ class Core(object):
...
@@ -204,13 +204,13 @@ class Core(object):
# migrate old database file names to new ones
# migrate old database file names to new ones
if
os
.
path
.
isfile
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickbeard.db'
))):
if
os
.
path
.
isfile
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickbeard.db'
))):
if
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
)):
if
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
)):
helpers
.
move
F
ile
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
),
helpers
.
move
_f
ile
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
),
os
.
path
.
join
(
self
.
data_dir
,
'{}.bak-{}'
os
.
path
.
join
(
self
.
data_dir
,
'{}.bak-{}'
.
format
(
'sickrage.db'
,
.
format
(
'sickrage.db'
,
datetime
.
datetime
.
now
().
strftime
(
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))))
'%Y%m%d_%H%M%S'
))))
helpers
.
move
F
ile
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickbeard.db'
)),
helpers
.
move
_f
ile
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickbeard.db'
)),
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
)))
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
)))
# load config
# load config
...
...
sickrage/core/caches/image_cache.py
View file @
eca1d42f
...
@@ -28,7 +28,7 @@ from hachoir_metadata import extractMetadata
...
@@ -28,7 +28,7 @@ from hachoir_metadata import extractMetadata
from
hachoir_parser
import
guessParser
from
hachoir_parser
import
guessParser
import
sickrage
import
sickrage
from
sickrage.core.helpers
import
copy
F
ile
from
sickrage.core.helpers
import
copy
_f
ile
from
sickrage.metadata
import
GenericMetadata
from
sickrage.metadata
import
GenericMetadata
...
@@ -226,7 +226,7 @@ class ImageCache(object):
...
@@ -226,7 +226,7 @@ class ImageCache(object):
os
.
makedirs
(
self
.
_thumbnails_dir
())
os
.
makedirs
(
self
.
_thumbnails_dir
())
sickrage
.
app
.
log
.
info
(
"Copying from "
+
image_path
+
" to "
+
dest_path
)
sickrage
.
app
.
log
.
info
(
"Copying from "
+
image_path
+
" to "
+
dest_path
)
copy
F
ile
(
image_path
,
dest_path
)
copy
_f
ile
(
image_path
,
dest_path
)
return
True
return
True
...
...
sickrage/core/config.py
View file @
eca1d42f
...
@@ -433,6 +433,7 @@ class Config(object):
...
@@ -433,6 +433,7 @@ class Config(object):
self
.
calendar_icons
=
False
self
.
calendar_icons
=
False
self
.
no_restart
=
False
self
.
no_restart
=
False
self
.
allowed_video_file_exts
=
[]
self
.
allowed_video_file_exts
=
[]
self
.
strip_special_file_bits
=
False
self
.
thetvdb_apitoken
=
""
self
.
thetvdb_apitoken
=
""
self
.
trakt_api_key
=
'5c65f55e11d48c35385d9e8670615763a605fad28374c8ae553a7b7a50651ddd'
self
.
trakt_api_key
=
'5c65f55e11d48c35385d9e8670615763a605fad28374c8ae553a7b7a50651ddd'
self
.
trakt_api_secret
=
'b53e32045ac122a445ef163e6d859403301ffe9b17fb8321d428531b69022a82'
self
.
trakt_api_secret
=
'b53e32045ac122a445ef163e6d859403301ffe9b17fb8321d428531b69022a82'
...
@@ -830,7 +831,8 @@ class Config(object):
...
@@ -830,7 +831,8 @@ class Config(object):
'keep_processed_dir'
:
True
,
'keep_processed_dir'
:
True
,
'processor_follow_symlinks'
:
False
,
'processor_follow_symlinks'
:
False
,
'allowed_extensions'
:
'srt,nfo,srr,sfv'
,
'allowed_extensions'
:
'srt,nfo,srr,sfv'
,
'view_changelog'
:
False
'view_changelog'
:
False
,
'strip_special_file_bits'
:
True
},
},
'NZBget'
:
{
'NZBget'
:
{
'nzbget_host'
:
''
,
'nzbget_host'
:
''
,
...
@@ -1517,6 +1519,7 @@ class Config(object):
...
@@ -1517,6 +1519,7 @@ class Config(object):
self
.
random_user_agent
=
self
.
check_setting_bool
(
'General'
,
'random_user_agent'
)
self
.
random_user_agent
=
self
.
check_setting_bool
(
'General'
,
'random_user_agent'
)
self
.
allowed_extensions
=
self
.
check_setting_str
(
'General'
,
'allowed_extensions'
)
self
.
allowed_extensions
=
self
.
check_setting_str
(
'General'
,
'allowed_extensions'
)
self
.
view_changelog
=
self
.
check_setting_bool
(
'General'
,
'view_changelog'
)
self
.
view_changelog
=
self
.
check_setting_bool
(
'General'
,
'view_changelog'
)
self
.
strip_special_file_bits
=
self
.
check_setting_bool
(
'General'
,
'strip_special_file_bits'
)
# GUI SETTINGS
# GUI SETTINGS
self
.
gui_lang
=
self
.
check_setting_str
(
'GUI'
,
'gui_lang'
)
self
.
gui_lang
=
self
.
check_setting_str
(
'GUI'
,
'gui_lang'
)
...
@@ -2018,7 +2021,8 @@ class Config(object):
...
@@ -2018,7 +2021,8 @@ class Config(object):
'processor_follow_symlinks'
:
int
(
self
.
processor_follow_symlinks
),
'processor_follow_symlinks'
:
int
(
self
.
processor_follow_symlinks
),
'delete_non_associated_files'
:
int
(
self
.
delete_non_associated_files
),
'delete_non_associated_files'
:
int
(
self
.
delete_non_associated_files
),
'allowed_extensions'
:
self
.
allowed_extensions
,
'allowed_extensions'
:
self
.
allowed_extensions
,
'view_changelog'
:
int
(
self
.
view_changelog
)
'view_changelog'
:
int
(
self
.
view_changelog
),
'strip_special_file_bits'
:
int
(
self
.
strip_special_file_bits
)
},
},
'GUI'
:
{
'GUI'
:
{
'gui_lang'
:
self
.
gui_lang
,
'gui_lang'
:
self
.
gui_lang
,
...
...
sickrage/core/helpers/__init__.py
View file @
eca1d42f
...
@@ -21,6 +21,7 @@ from __future__ import unicode_literals
...
@@ -21,6 +21,7 @@ from __future__ import unicode_literals
import
base64
import
base64
import
ctypes
import
ctypes
import
datetime
import
datetime
import
errno
import
io
import
io
import
os
import
os
import
platform
import
platform
...
@@ -435,39 +436,42 @@ def list_media_files(path):
...
@@ -435,39 +436,42 @@ def list_media_files(path):
return
files
return
files
def
copy
F
ile
(
src
F
ile
,
dest
F
ile
):
def
copy
_f
ile
(
src
_f
ile
,
dest
_f
ile
):
"""
"""
Copy a file from source to destination
Copy a file from source to destination
:param src
F
ile: Path of source file
:param src
_f
ile: Path of source file
:param dest
F
ile: Path of destination file
:param dest
_f
ile: Path of destination file
"""
"""
try
:
try
:
shutil
.
copyfile
(
srcFile
,
destFile
)
shutil
.
copyfile
(
src_file
,
dest_file
)
except
Exception
as
e
:
except
OSError
as
e
:
sickrage
.
app
.
log
.
warning
(
str
(
e
))
if
e
.
errno
==
errno
.
ENOSPC
:
sickrage
.
app
.
log
.
warning
(
e
)
else
:
sickrage
.
app
.
log
.
error
(
e
)
else
:
else
:
try
:
try
:
shutil
.
copymode
(
src
F
ile
,
dest
F
ile
)
shutil
.
copymode
(
src
_f
ile
,
dest
_f
ile
)
except
OSError
:
except
OSError
:
pass
pass
def
move
F
ile
(
src
F
ile
,
dest
F
ile
):
def
move
_f
ile
(
src
_f
ile
,
dest
_f
ile
):
"""
"""
Move a file from source to destination
Move a file from source to destination
:param src
F
ile: Path of source file
:param src
_f
ile: Path of source file
:param dest
F
ile: Path of destination file
:param dest
_f
ile: Path of destination file
"""
"""
try
:
try
:
shutil
.
move
(
src
F
ile
,
dest
F
ile
)
shutil
.
move
(
src
_f
ile
,
dest
_f
ile
)
fix
SetG
roup
ID
(
dest
F
ile
)
fix
_set_g
roup
_id
(
dest
_f
ile
)
except
OSError
:
except
OSError
:
copy
F
ile
(
src
F
ile
,
dest
F
ile
)
copy
_f
ile
(
src
_f
ile
,
dest
_f
ile
)
os
.
unlink
(
src
F
ile
)
os
.
unlink
(
src
_f
ile
)
def
link
(
src
,
dst
):
def
link
(
src
,
dst
):
...
@@ -486,21 +490,27 @@ def link(src, dst):
...
@@ -486,21 +490,27 @@ def link(src, dst):
os
.
link
(
src
,
dst
)
os
.
link
(
src
,
dst
)
def
hardlink
F
ile
(
src
F
ile
,
dest
F
ile
):
def
hardlink
_f
ile
(
src
_f
ile
,
dest
_f
ile
):
"""
"""
Create a hard-link (inside filesystem link) between source and destination
Create a hard-link (inside filesystem link) between source and destination
:param src
F
ile: Source file
:param src
_f
ile: Source file
:param dest
F
ile: Destination file
:param dest
_f
ile: Destination file
"""
"""
try
:
try
:
link
(
srcFile
,
destFile
)
link
(
src_file
,
dest_file
)
fixSetGroupID
(
destFile
)
fix_set_group_id
(
dest_file
)
except
Exception
as
e
:
except
OSError
as
e
:
sickrage
.
app
.
log
.
warning
(
"Failed to create hardlink of %s at %s. Error: %r. Copying instead"
if
e
.
errno
==
errno
.
EEXIST
:
%
(
srcFile
,
destFile
,
e
))
# File exists. Don't fallback to copy
copyFile
(
srcFile
,
destFile
)
sickrage
.
app
.
log
.
warning
(
'Failed to create hardlink of {src} at {dest}. Error: {error!r}'
.
format
(
**
{
'src'
:
src_file
,
'dest'
:
dest_file
,
'error'
:
e
}))
else
:
sickrage
.
app
.
log
.
warning
(
"Failed to create hardlink of {src} at {dest}. Error: {error!r}. Copying instead"
.
format
(
**
{
'src'
:
src_file
,
'dest'
:
dest_file
,
'error'
:
e
}))
copy_file
(
src_file
,
dest_file
)
def
symlink
(
src
,
dst
):
def
symlink
(
src
,
dst
):
...
@@ -519,23 +529,28 @@ def symlink(src, dst):
...
@@ -519,23 +529,28 @@ def symlink(src, dst):
os
.
symlink
(
src
,
dst
)
os
.
symlink
(
src
,
dst
)
def
move
AndS
ymlink
F
ile
(
src
F
ile
,
dest
F
ile
):
def
move
_and_s
ymlink
_f
ile
(
src
_f
ile
,
dest
_f
ile
):
"""
"""
Move a file from source to destination, then create a symlink back from destination from source. If this fails, copy
Move a file from source to destination, then create a symlink back from destination from source. If this fails, copy
the file from source to destination
the file from source to destination
:param src
F
ile: Source file
:param src
_f
ile: Source file
:param dest
F
ile: Destination file
:param dest
_f
ile: Destination file
"""
"""
try
:
try
:
shutil
.
move
(
srcFile
,
destFile
)
shutil
.
move
(
src_file
,
dest_file
)
fixSetGroupID
(
destFile
)
fix_set_group_id
(
dest_file
)
symlink
(
destFile
,
srcFile
)
symlink
(
dest_file
,
src_file
)
except
Exception
as
e
:
except
OSError
as
e
:
sickrage
.
app
.
log
.
warning
(
"Failed to create symlink of %s at %s. Error: %r. Copying instead"
if
e
.
errno
==
errno
.
EEXIST
:
%
(
srcFile
,
destFile
,
e
))
# File exists. Don't fallback to copy
copyFile
(
srcFile
,
destFile
)
sickrage
.
app
.
log
.
warning
(
'Failed to create symlink of {src} at {dest}. Error: {error!r}'
.
format
(
**
{
'src'
:
src_file
,
'dest'
:
dest_file
,
'error'
:
e
}))
else
:
sickrage
.
app
.
log
.
warning
(
"Failed to create symlink of {src} at {dest}. Error: {error!r}. Copying instead"
.
format
(
**
{
'src'
:
src_file
,
'dest'
:
dest_file
,
'error'
:
e
}))
copy_file
(
src_file
,
dest_file
)
def
make_dirs
(
path
):
def
make_dirs
(
path
):
...
@@ -573,7 +588,7 @@ def make_dirs(path):
...
@@ -573,7 +588,7 @@ def make_dirs(path):
sickrage
.
app
.
log
.
debug
(
"Folder %s didn't exist, creating it"
%
sofar
)
sickrage
.
app
.
log
.
debug
(
"Folder %s didn't exist, creating it"
%
sofar
)
os
.
mkdir
(
sofar
)
os
.
mkdir
(
sofar
)
# use normpath to remove end separator, otherwise checks permissions against itself
# use normpath to remove end separator, otherwise checks permissions against itself
chmod
AsP
arent
(
os
.
path
.
normpath
(
sofar
))
chmod
_as_p
arent
(
os
.
path
.
normpath
(
sofar
))
# do the library update for synoindex
# do the library update for synoindex
sickrage
.
app
.
notifier_providers
[
'synoindex'
].
addFolder
(
sofar
)
sickrage
.
app
.
notifier_providers
[
'synoindex'
].
addFolder
(
sofar
)
except
(
OSError
,
IOError
)
as
e
:
except
(
OSError
,
IOError
)
as
e
:
...
@@ -621,7 +636,7 @@ def delete_empty_folders(check_empty_dir, keep_dir=None):
...
@@ -621,7 +636,7 @@ def delete_empty_folders(check_empty_dir, keep_dir=None):
pass
pass
def
file
BitF
ilter
(
mode
):
def
file
_bit_f
ilter
(
mode
):
"""
"""
Strip special filesystem bits from file
Strip special filesystem bits from file
...
@@ -636,9 +651,10 @@ def fileBitFilter(mode):
...
@@ -636,9 +651,10 @@ def fileBitFilter(mode):
return
mode
return
mode
def
chmod
AsP
arent
(
child
P
ath
):
def
chmod
_as_p
arent
(
child
_p
ath
):
"""
"""
Retain permissions of parent for childs
Retain permissions of parent for childs
(Does not work for Windows hosts)
(Does not work for Windows hosts)
:param childPath: Child Path to change permissions to sync from parent
:param childPath: Child Path to change permissions to sync from parent
...
@@ -647,82 +663,85 @@ def chmodAsParent(childPath):
...
@@ -647,82 +663,85 @@ def chmodAsParent(childPath):
if
os
.
name
==
'nt'
or
os
.
name
==
'ce'
:
if
os
.
name
==
'nt'
or
os
.
name
==
'ce'
:
return
return
parent
P
ath
=
os
.
path
.
dirname
(
child
P
ath
)
parent
_p
ath
=
os
.
path
.
dirname
(
child
_p
ath
)
if
not
parent
P
ath
:
if
not
parent
_p
ath
:
sickrage
.
app
.
log
.
debug
(
"No parent path provided in "
+
child
P
ath
+
", unable to get permissions from it"
)
sickrage
.
app
.
log
.
debug
(
"No parent path provided in "
+
child
_p
ath
+
", unable to get permissions from it"
)
return
return
childPath
=
os
.
path
.
join
(
parentPath
,
os
.
path
.
basename
(
childPath
))
child_path
=
os
.
path
.
join
(
parent_path
,
os
.
path
.
basename
(
child_path
))
if
not
os
.
path
.
exists
(
child_path
):
return
parent
P
ath
S
tat
=
os
.
stat
(
parent
P
ath
)
parent
_p
ath
_s
tat
=
os
.
stat
(
parent
_p
ath
)
parent
M
ode
=
stat
.
S_IMODE
(
parent
P
ath
S
tat
[
stat
.
ST_MODE
])
parent
_m
ode
=
stat
.
S_IMODE
(
parent
_p
ath
_s
tat
[
stat
.
ST_MODE
])
child
P
ath
S
tat
=
os
.
stat
(
child
P
ath
)
child
_p
ath
_s
tat
=
os
.
stat
(
child
_p
ath
)
child
P
ath_mode
=
stat
.
S_IMODE
(
child
P
ath
S
tat
[
stat
.
ST_MODE
])
child
_p
ath_mode
=
stat
.
S_IMODE
(
child
_p
ath
_s
tat
[
stat
.
ST_MODE
])
if
os
.
path
.
isfile
(
child
P
ath
):
if
os
.
path
.
isfile
(
child
_p
ath
)
and
sickrage
.
app
.
config
.
strip_special_file_bits
:
child
M
ode
=
file
BitF
ilter
(
parent
M
ode
)
child
_m
ode
=
file
_bit_f
ilter
(
parent
_m
ode
)
else
:
else
:
child
M
ode
=
parent
M
ode
child
_m
ode
=
parent
_m
ode
if
child
P
ath_mode
==
child
M
ode
:
if
child
_p
ath_mode
==
child
_m
ode
:
return
return
child
P
ath_owner
=
child
P
ath
S
tat
.
st_uid
child
_p
ath_owner
=
child
_p
ath
_s
tat
.
st_uid
user_id
=
os
.
geteuid
()
user_id
=
os
.
geteuid
()
if
user_id
!=
0
and
user_id
!=
child
P
ath_owner
:
if
user_id
not
in
(
0
,
child
_p
ath_owner
)
:
sickrage
.
app
.
log
.
debug
(
"Not running as root or owner of "
+
child
P
ath
+
", not trying to set permissions"
)
sickrage
.
app
.
log
.
debug
(
"Not running as root or owner of "
+
child
_p
ath
+
", not trying to set permissions"
)
return
return
try
:
try
:
os
.
chmod
(
child
P
ath
,
child
M
ode
)
os
.
chmod
(
child
_p
ath
,
child
_m
ode
)
sickrage
.
app
.
log
.
debug
(
sickrage
.
app
.
log
.
debug
(
"Setting permissions for %s to %o as parent directory has %o"
%
(
child
P
ath
,
child
M
ode
,
parent
M
ode
))
"Setting permissions for %s to %o as parent directory has %o"
%
(
child
_p
ath
,
child
_m
ode
,
parent
_m
ode
))
except
OSError
:
except
OSError
:
sickrage
.
app
.
log
.
debug
(
"Failed to set permission for %s to %o"
%
(
child
P
ath
,
child
M
ode
))
sickrage
.
app
.
log
.
debug
(
"Failed to set permission for %s to %o"
%
(
child
_p
ath
,
child
_m
ode
))
def
fix
SetG
roup
ID
(
child
P
ath
):
def
fix
_set_g
roup
_id
(
child
_p
ath
):
"""
"""
Inherid SGID from parent
Inherit SGID from parent
(does not work on Windows hosts)
(does not work on Windows hosts)
:param child
P
ath: Path to inherit SGID permissions from parent
:param child
_p
ath: Path to inherit SGID permissions from parent
"""
"""
if
os
.
name
==
'nt'
or
os
.
name
==
'ce'
:
if
os
.
name
==
'nt'
or
os
.
name
==
'ce'
:
return
return
parent
P
ath
=
os
.
path
.
dirname
(
child
P
ath
)
parent
_p
ath
=
os
.
path
.
dirname
(
child
_p
ath
)
parent
S
tat
=
os
.
stat
(
parent
P
ath
)
parent
_s
tat
=
os
.
stat
(
parent
_p
ath
)
parent
M
ode
=
stat
.
S_IMODE
(
parent
S
tat
[
stat
.
ST_MODE
])
parent
_m
ode
=
stat
.
S_IMODE
(
parent
_s
tat
[
stat
.
ST_MODE
])
child
P
ath
=
os
.
path
.
join
(
parent
P
ath
,
os
.
path
.
basename
(
child
P
ath
))
child
_p
ath
=
os
.
path
.
join
(
parent
_p
ath
,
os
.
path
.
basename
(
child
_p
ath
))
if
parent
M
ode
&
stat
.
S_ISGID
:
if
parent
_m
ode
&
stat
.
S_ISGID
:
parent
GID
=
parent
S
tat
[
stat
.
ST_GID
]
parent
_gid
=
parent
_s
tat
[
stat
.
ST_GID
]
child
S
tat
=
os
.
stat
(
child
P
ath
)
child
_s
tat
=
os
.
stat
(
child
_p
ath
)
child
GID
=
child
S
tat
[
stat
.
ST_GID
]
child
_gid
=
child
_s
tat
[
stat
.
ST_GID
]
if
child
GID
==
parent
GID
:
if
child
_gid
==
parent
_gid
:
return
return
child
P
ath_owner
=
child
S
tat
.
st_uid
child
_p
ath_owner
=
child
_s
tat
.
st_uid
user_id
=
os
.
geteuid
()
user_id
=
os
.
geteuid
()
if
user_id
!=
0
and
user_id
!=
child
P
ath_owner
:
if
user_id
not
in
(
0
,
child
_p
ath_owner
)
:
sickrage
.
app
.
log
.
debug
(
sickrage
.
app
.
log
.
debug
(
"Not running as root or owner of {}, not trying to set the set-group-ID"
.
format
(
child
P
ath
))
"Not running as root or owner of {}, not trying to set the set-group-ID"
.
format
(
child
_p
ath
))
return
return
try
:
try
:
os
.
chown
(
child
P
ath
,
-
1
,
parent
GID
)
# @UndefinedVariable - only available on UNIX
os
.
chown
(
child
_p
ath
,
-
1
,
parent
_gid
)
sickrage
.
app
.
log
.
debug
(
"Respecting the set-group-ID bit on the parent directory for {}"
.
format
(
child
P
ath
))
sickrage
.
app
.
log
.
debug
(
"Respecting the set-group-ID bit on the parent directory for {}"
.
format
(
child
_p
ath
))
except
OSError
:
except
OSError
:
sickrage
.
app
.
log
.
error
(
"Failed to respect the set-group-ID bit on the parent directory for {} (setting "
sickrage
.
app
.
log
.
error
(
"Failed to respect the set-group-ID bit on the parent directory for {} (setting "
"group ID {})"
.
format
(
child
P
ath
,
parent
GID
))
"group ID {})"
.
format
(
child
_p
ath
,
parent
_gid
))
def
sanitizeSceneName
(
name
,
anime
=
False
):
def
sanitizeSceneName
(
name
,
anime
=
False
):
...
@@ -948,7 +967,7 @@ def restoreConfigZip(archive, targetDir, restore_database=True, restore_config=T
...
@@ -948,7 +967,7 @@ def restoreConfigZip(archive, targetDir, restore_database=True, restore_config=T
return
tail
or
os
.
path
.
basename
(
head
)
return
tail
or
os
.
path
.
basename
(
head
)
bakFilename
=
'{0}-{1}'
.
format
(
path_leaf
(
targetDir
),
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))
bakFilename
=
'{0}-{1}'
.
format
(
path_leaf
(
targetDir
),
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))
move
F
ile
(
targetDir
,
os
.
path
.
join
(
os
.
path
.
dirname
(
targetDir
),
bakFilename
))
move
_f
ile
(
targetDir
,
os
.
path
.
join
(
os
.
path
.
dirname
(
targetDir
),
bakFilename
))
with
zipfile
.
ZipFile
(
archive
,
'r'
,
allowZip64
=
True
)
as
zip_file
:
with
zipfile
.
ZipFile
(
archive
,
'r'
,
allowZip64
=
True
)
as
zip_file
:
for
member
in
zip_file
.
namelist
():
for
member
in
zip_file
.
namelist
():
...
@@ -1029,26 +1048,26 @@ def restoreSR(srcDir, dstDir):
...
@@ -1029,26 +1048,26 @@ def restoreSR(srcDir, dstDir):
if
os
.
path
.
exists
(
srcFile
):
if
os
.
path
.
exists
(
srcFile
):
if
os
.
path
.
isfile
(
dstFile
):
if
os
.
path
.
isfile
(
dstFile
):
move
F
ile
(
dstFile
,
bakFile
)
move
_f
ile
(
dstFile
,
bakFile
)
move
F
ile
(
srcFile
,
dstFile
)
move
_f
ile
(
srcFile
,
dstFile
)
# databse
# databse
if
os
.
path
.
exists
(
os
.
path
.
join
(
srcDir
,
'database'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
srcDir
,
'database'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
dstDir
,
'database'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
dstDir
,
'database'
)):
move
F
ile
(
os
.
path
.
join
(
dstDir
,
'database'
),
os
.
path
.
join
(
dstDir
,
'{}.bak-{}'
move
_f
ile
(
os
.
path
.
join
(
dstDir
,
'database'
),
os
.
path
.
join
(
dstDir
,
'{}.bak-{}'
.
format
(
'database'
,
.
format
(
'database'
,
datetime
.
datetime
.
now
().
strftime
(
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))))
'%Y%m%d_%H%M%S'
))))
move
F
ile
(
os
.
path
.
join
(
srcDir
,
'database'
),
dstDir
)
move
_f
ile
(
os
.
path
.
join
(
srcDir
,
'database'
),
dstDir
)
# cache
# cache
if
os
.
path
.
exists
(
os
.
path
.
join
(
srcDir
,
'cache'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
srcDir
,
'cache'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
dstDir
,
'cache'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
dstDir
,
'cache'
)):
move
F
ile
(
os
.
path
.
join
(
dstDir
,
'cache'
),
os
.
path
.
join
(
dstDir
,
'{}.bak-{}'
move
_f
ile
(
os
.
path
.
join
(
dstDir
,
'cache'
),
os
.
path
.
join
(
dstDir
,
'{}.bak-{}'
.
format
(
'cache'
,
.
format
(
'cache'
,
datetime
.
datetime
.
now
().
strftime
(
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))))
'%Y%m%d_%H%M%S'
))))
move
F
ile
(
os
.
path
.
join
(
srcDir
,
'cache'
),
dstDir
)
move
_f
ile
(
os
.
path
.
join
(
srcDir
,
'cache'
),
dstDir
)
return
True
return
True
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -1357,7 +1376,7 @@ def restoreVersionedFile(backup_file, version):
...
@@ -1357,7 +1376,7 @@ def restoreVersionedFile(backup_file, version):
sickrage
.
app
.
log
.
debug
(
"Trying to backup %s to %s.r%s before restoring backup"
sickrage
.
app
.
log
.
debug
(
"Trying to backup %s to %s.r%s before restoring backup"
%
(
new_file
,
new_file
,
version
))
%
(
new_file
,
new_file
,
version
))
move
F
ile
(
new_file
,
new_file
+
'.'
+
'r'
+
str
(
version
))
move
_f
ile
(
new_file
,
new_file
+
'.'
+
'r'
+
str
(
version
))
except
Exception
as
e
:
except
Exception
as
e
:
sickrage
.
app
.
log
.
warning
(
"Error while trying to backup file %s before proceeding with restore: %r"
sickrage
.
app
.
log
.
warning
(
"Error while trying to backup file %s before proceeding with restore: %r"
%
(
restore_file
,
e
))
%
(
restore_file
,
e
))
...
...
sickrage/core/processors/post_processor.py
View file @
eca1d42f
...
@@ -31,7 +31,8 @@ from sickrage.core.common import Quality, ARCHIVED, DOWNLOADED
...
@@ -31,7 +31,8 @@ from sickrage.core.common import Quality, ARCHIVED, DOWNLOADED
from
sickrage.core.exceptions
import
EpisodeNotFoundException
,
EpisodePostProcessingFailedException
,
\
from
sickrage.core.exceptions
import
EpisodeNotFoundException
,
EpisodePostProcessingFailedException
,
\
NoFreeSpaceException
NoFreeSpaceException
from
sickrage.core.helpers
import
findCertainShow
,
show_names
,
replaceExtension
,
makeDir
,
\
from
sickrage.core.helpers
import
findCertainShow
,
show_names
,
replaceExtension
,
makeDir
,
\
chmodAsParent
,
moveFile
,
copyFile
,
hardlinkFile
,
moveAndSymlinkFile
,
remove_non_release_groups
,
remove_extension
,
\
chmod_as_parent
,
move_file
,
copy_file
,
hardlink_file
,
move_and_symlink_file
,
remove_non_release_groups
,
\
remove_extension
,
\
isFileLocked
,
verify_freespace
,
delete_empty_folders
,
make_dirs
,
symlink
,
is_rar_file
,
glob_escape
isFileLocked
,
verify_freespace
,
delete_empty_folders
,
make_dirs
,
symlink
,
is_rar_file
,
glob_escape
from
sickrage.core.nameparser
import
InvalidNameException
,
InvalidShowException
,
\
from
sickrage.core.nameparser
import
InvalidNameException
,
InvalidShowException
,
\
NameParser
NameParser
...
@@ -365,7 +366,7 @@ class PostProcessor(object):
...
@@ -365,7 +366,7 @@ class PostProcessor(object):
if
not
dir_exists
:
if
not
dir_exists
:
sickrage
.
app
.
log
.
warning
(
"Unable to create subtitles folder "
+
subs_new_path
)
sickrage
.
app
.
log
.
warning
(
"Unable to create subtitles folder "
+
subs_new_path
)
else
:
else
:
chmod
AsP
arent
(
subs_new_path
)
chmod
_as_p
arent
(
subs_new_path
)
new_file_path
=
os
.
path
.
join
(
subs_new_path
,
new_file_name
)
new_file_path
=
os
.
path
.
join
(
subs_new_path
,
new_file_name
)
else
:
else