Browse Source

Merge branch 'hotfix/0.25.8'

tags/release_0.25.8^0 release_0.25.8
JackDandy 4 years ago
parent
commit
8f4ca3637e
  1. 7
      CHANGES.md
  2. 33
      lib/diskcache_py2/core.py
  3. 32
      lib/diskcache_py3/core.py
  4. 31
      lib/sg_helpers.py
  5. 24
      sickbeard/helpers.py

7
CHANGES.md

@ -1,4 +1,9 @@
### 0.25.7 (2021-09-29 18:40:00 UTC) ### 0.25.8 (2021-10-10 21:00:00 UTC)
* Fix add show and browse TVmaze cards on Solaris Hipster
### 0.25.7 (2021-09-29 18:40:00 UTC)
* Fix ignore entire show runtimes when getting runtimes from IMDb * Fix ignore entire show runtimes when getting runtimes from IMDb
* Change enable failure monitor for search_tvs * Change enable failure monitor for search_tvs

33
lib/diskcache_py2/core.py

@ -20,6 +20,8 @@ import time
import warnings import warnings
import zlib import zlib
from sg_helpers import touch_file
############################################################################ ############################################################################
# BEGIN Python 2/3 Shims # BEGIN Python 2/3 Shims
############################################################################ ############################################################################
@ -647,10 +649,10 @@ class Cache(object):
con = getattr(self._local, 'con', None) con = getattr(self._local, 'con', None)
if con is None: if con is None:
touch_file(DBNAME, dir_name=self._directory)
con = self._local.con = sqlite3.connect( con = self._local.con = sqlite3.connect(
op.join(self._directory, DBNAME), op.join(self._directory, DBNAME),
timeout=self._timeout, timeout=self._timeout
isolation_level=None,
) )
# Some SQLite pragmas work on a per-connection basis so # Some SQLite pragmas work on a per-connection basis so
@ -671,9 +673,18 @@ class Cache(object):
return con return con
def _execute(self, *args, **kwargs):
result = self._con.execute(*args, **kwargs)
try:
self._con.commit()
except (BaseException, Exception):
pass
return result
@property @property
def _sql(self): def _sql(self):
return self._con.execute return self._execute
@property @property
@ -699,7 +710,7 @@ class Cache(object):
diff = time.time() - start diff = time.time() - start
if diff > 60: if diff > 60:
raise raise
time.sleep(0.001) time.sleep(1)
return _execute_with_retry return _execute_with_retry
@ -749,7 +760,7 @@ class Cache(object):
else: else:
while True: while True:
try: try:
sql('BEGIN IMMEDIATE') #sql('BEGIN IMMEDIATE')
begin = True begin = True
self._txn_id = tid self._txn_id = tid
break break
@ -766,13 +777,15 @@ class Cache(object):
if begin: if begin:
assert self._txn_id == tid assert self._txn_id == tid
self._txn_id = None self._txn_id = None
sql('ROLLBACK') #sql('ROLLBACK')
self._con.rollback()
raise raise
else: else:
if begin: if begin:
assert self._txn_id == tid assert self._txn_id == tid
self._txn_id = None self._txn_id = None
sql('COMMIT') #sql('COMMIT')
self._con.commit()
for name in filenames: for name in filenames:
if name is not None: if name is not None:
_disk_remove(name) _disk_remove(name)
@ -2373,6 +2386,10 @@ class Cache(object):
if con is None: if con is None:
return return
try:
con.commit()
except (BaseException, Exception):
pass
con.close() con.close()
try: try:
@ -2479,7 +2496,7 @@ class Cache(object):
diff = time.time() - start diff = time.time() - start
if diff > 60: if diff > 60:
raise raise
time.sleep(0.001) time.sleep(1)
elif key.startswith('disk_'): elif key.startswith('disk_'):
attr = key[5:] attr = key[5:]
setattr(self._disk, attr, value) setattr(self._disk, attr, value)

32
lib/diskcache_py3/core.py

@ -20,6 +20,7 @@ import time
import warnings import warnings
import zlib import zlib
from sg_helpers import touch_file
def full_name(func): def full_name(func):
"Return full name of `func` by adding the module and function name." "Return full name of `func` by adding the module and function name."
@ -615,10 +616,10 @@ class Cache(object):
con = getattr(self._local, 'con', None) con = getattr(self._local, 'con', None)
if con is None: if con is None:
touch_file(DBNAME, dir_name=self._directory)
con = self._local.con = sqlite3.connect( con = self._local.con = sqlite3.connect(
op.join(self._directory, DBNAME), op.join(self._directory, DBNAME),
timeout=self._timeout, timeout=self._timeout
isolation_level=None,
) )
# Some SQLite pragmas work on a per-connection basis so # Some SQLite pragmas work on a per-connection basis so
@ -639,9 +640,18 @@ class Cache(object):
return con return con
def _execute(self, *args, **kwargs):
result = self._con.execute(*args, **kwargs)
try:
self._con.commit()
except (BaseException, Exception):
pass
return result
@property @property
def _sql(self): def _sql(self):
return self._con.execute return self._execute
@property @property
@ -667,7 +677,7 @@ class Cache(object):
diff = time.time() - start diff = time.time() - start
if diff > 60: if diff > 60:
raise raise
time.sleep(0.001) time.sleep(1)
return _execute_with_retry return _execute_with_retry
@ -717,7 +727,7 @@ class Cache(object):
else: else:
while True: while True:
try: try:
sql('BEGIN IMMEDIATE') # sql('BEGIN IMMEDIATE', no_commit_call=True)
begin = True begin = True
self._txn_id = tid self._txn_id = tid
break break
@ -734,13 +744,15 @@ class Cache(object):
if begin: if begin:
assert self._txn_id == tid assert self._txn_id == tid
self._txn_id = None self._txn_id = None
sql('ROLLBACK') # sql('ROLLBACK')
self._con.rollback()
raise raise
else: else:
if begin: if begin:
assert self._txn_id == tid assert self._txn_id == tid
self._txn_id = None self._txn_id = None
sql('COMMIT') # sql('COMMIT')
self._con.commit()
for name in filenames: for name in filenames:
if name is not None: if name is not None:
_disk_remove(name) _disk_remove(name)
@ -2338,6 +2350,10 @@ class Cache(object):
if con is None: if con is None:
return return
try:
con.commit()
except (BaseException, Exception):
pass
con.close() con.close()
try: try:
@ -2444,7 +2460,7 @@ class Cache(object):
diff = time.time() - start diff = time.time() - start
if diff > 60: if diff > 60:
raise raise
time.sleep(0.001) time.sleep(1)
elif key.startswith('disk_'): elif key.startswith('disk_'):
attr = key[5:] attr = key[5:]
setattr(self._disk, attr, value) setattr(self._disk, attr, value)

31
lib/sg_helpers.py

@ -1678,3 +1678,34 @@ def spoken_height(height):
:param height: height in cm :param height: height in cm
""" """
return convert_to_inch_faction_html(height).replace('\'', ' foot').replace('"', '') return convert_to_inch_faction_html(height).replace('\'', ' foot').replace('"', '')
def touch_file(fname, atime=None, dir_name=None):
"""
set access time of given file
:param fname: filename
:type fname: AnyStr
:param atime: access time as epoch
:type atime: int
:param: dir_name: directory name
:type dir_name: AnyStr
:return: success
:rtype: bool
"""
if None is not dir_name:
fname = ek.ek(os.path.join, dir_name, fname)
if make_dirs(dir_name):
if not ek.ek(os.path.exists, fname):
with io.open(fname, 'w') as fh:
fh.flush()
if None is not atime:
try:
with open(fname, 'a'):
ek.ek(os.utime, fname, (atime, atime))
return True
except (BaseException, Exception):
logger.debug('File air date stamping not available on your OS')
return False

24
sickbeard/helpers.py

@ -62,7 +62,7 @@ from six.moves import zip
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
from sg_helpers import chmod_as_parent, clean_data, copy_file, download_file, fix_set_group_id, get_system_temp_dir, \ from sg_helpers import chmod_as_parent, clean_data, copy_file, download_file, fix_set_group_id, get_system_temp_dir, \
get_url, indent_xml, make_dirs, maybe_plural, md5_for_text, move_file, proxy_setting, remove_file, \ get_url, indent_xml, make_dirs, maybe_plural, md5_for_text, move_file, proxy_setting, remove_file, \
remove_file_perm, replace_extension, sanitize_filename, scantree, try_int, try_ord, write_file remove_file_perm, replace_extension, sanitize_filename, scantree, touch_file, try_int, try_ord, write_file
# noinspection PyUnreachableCode # noinspection PyUnreachableCode
if False: if False:
@ -1021,28 +1021,6 @@ def validate_show(show_obj, season=None, episode=None):
pass pass
def touch_file(fname, atime=None):
"""
set access time of given file
:param fname: filename
:type fname: AnyStr
:param atime: access time as epoch
:type atime: int
:return: success
:rtype: bool
"""
if None is not atime:
try:
with open(fname, 'a'):
ek.ek(os.utime, fname, (atime, atime))
return True
except (BaseException, Exception):
logger.log('File air date stamping not available on your OS', logger.DEBUG)
return False
def _maybe_request_url(e, def_url=''): def _maybe_request_url(e, def_url=''):
return hasattr(e, 'request') and hasattr(e.request, 'url') and ' ' + e.request.url or def_url return hasattr(e, 'request') and hasattr(e.request, 'url') and ' ' + e.request.url or def_url

Loading…
Cancel
Save