Browse Source

Fix add show and browse TVmaze cards on Solaris Hipster.

Change relocate touch_file and make it create a supplied dir and file if not existing.
Change use touch_file to create cache.db files, instead of failing sqlite.connect().
Change backport add SQL transaction commit to diskcache.
tags/release_0.25.8^2
JackDandy 4 years ago
parent
commit
a81f0b8526
  1. 7
      CHANGES.md
  2. 33
      lib/diskcache_py2/core.py
  3. 4
      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
* Change enable failure monitor for search_tvs

33
lib/diskcache_py2/core.py

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

4
lib/diskcache_py3/core.py

@ -20,6 +20,7 @@ import time
import warnings
import zlib
from sg_helpers import touch_file
def full_name(func):
"Return full name of `func` by adding the module and function name."
@ -615,6 +616,7 @@ class Cache(object):
con = getattr(self._local, 'con', None)
if con is None:
touch_file(DBNAME, dir_name=self._directory)
con = self._local.con = sqlite3.connect(
op.join(self._directory, DBNAME),
timeout=self._timeout
@ -2458,7 +2460,7 @@ class Cache(object):
diff = time.time() - start
if diff > 60:
raise
time.sleep(0.001)
time.sleep(1)
elif key.startswith('disk_'):
attr = key[5:]
setattr(self._disk, attr, value)

31
lib/sg_helpers.py

@ -1678,3 +1678,34 @@ def spoken_height(height):
:param height: height in cm
"""
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
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, \
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
if False:
@ -1021,28 +1021,6 @@ def validate_show(show_obj, season=None, episode=None):
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=''):
return hasattr(e, 'request') and hasattr(e.request, 'url') and ' ' + e.request.url or def_url

Loading…
Cancel
Save