提交 950d891b 编写于 作者: H Hou Tianze

- Close #437: Ensure cache loading/saving failures won't affect normal operations

- Fix the bug that clean up code not called on exit
- Version bump
上级 206c1c73
### Version History: ### Version History:
- 1.6.1: Ensure cache loading/saving failures won't affect normal operations; Fix the bug that clean up code not called on exit
- 1.6.0: Fix 1000 items limit for remote directory listing - 1.6.0: Fix 1000 items limit for remote directory listing
- 1.5.13: Fix multiprocess upload/syncup missing some files - 1.5.13: Fix multiprocess upload/syncup missing some files
- 1.5.12: Add one more heroku server; Workaround "ValueError: unknown locale: UTF-8" on macOs (by xslidian) - 1.5.12: Add one more heroku server; Workaround "ValueError: unknown locale: UTF-8" on macOs (by xslidian)
......
Version History: Version History:
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
- 1.6.1: Ensure cache loading/saving failures won't affect normal
operations; Fix the bug that clean up code not called on exit
- 1.6.0: Fix 1000 items limit for remote directory listing - 1.6.0: Fix 1000 items limit for remote directory listing
- 1.5.13: Fix multiprocess upload/syncup missing some files - 1.5.13: Fix multiprocess upload/syncup missing some files
- 1.5.12: Add one more heroku server; Workaround "ValueError: unknown - 1.5.12: Add one more heroku server; Workaround "ValueError: unknown
......
...@@ -381,6 +381,8 @@ class ByPy(object): ...@@ -381,6 +381,8 @@ class ByPy(object):
# so if any code using this class can check the current verbose / debug level # so if any code using this class can check the current verbose / debug level
cached.verbose = self.verbose = verbose cached.verbose = self.verbose = verbose
cached.debug = self.debug = debug cached.debug = self.debug = debug
if not cached.usecache:
pinfo("Forced hash recaculation, hash cache won't be used")
#TODO: SSL verification causes some much trouble for different Python version #TODO: SSL verification causes some much trouble for different Python version
# I give up and disable it for good, or for bad # I give up and disable it for good, or for bad
...@@ -491,7 +493,7 @@ class ByPy(object): ...@@ -491,7 +493,7 @@ class ByPy(object):
"minimum required version is {}.\n" "minimum required version is {}.\n"
"Please run 'pip install -U bypy' to update and try again.".format( "Please run 'pip install -U bypy' to update and try again.".format(
const.__version__, minver)) const.__version__, minver))
quit(const.EUpdateNeeded) self.quit(const.EUpdateNeeded)
else: else:
self.__setting[const.SettingKey_LastUpdateCheckTime] = nowsec self.__setting[const.SettingKey_LastUpdateCheckTime] = nowsec
self.savesetting() self.savesetting()
...@@ -3561,6 +3563,7 @@ def clean_prog_files(cleanlevel, verbose, configdir = const.ConfigDir): ...@@ -3561,6 +3563,7 @@ def clean_prog_files(cleanlevel, verbose, configdir = const.ConfigDir):
def main(argv=None): # IGNORE:C0111 def main(argv=None): # IGNORE:C0111
''' Main Entry ''' ''' Main Entry '''
by = None
reqres = check_requirements() reqres = check_requirements()
if reqres == CheckResult.Error: if reqres == CheckResult.Error:
perr("Requirement checking failed") perr("Requirement checking failed")
...@@ -3687,8 +3690,9 @@ def main(argv=None): # IGNORE:C0111 ...@@ -3687,8 +3690,9 @@ def main(argv=None): # IGNORE:C0111
perr("Exception occurred:\n{}".format(formatex(ex))) perr("Exception occurred:\n{}".format(formatex(ex)))
pr("Abort") pr("Abort")
raise raise
finally:
quit(result) if by:
by.quit(result)
if __name__ == "__main__": if __name__ == "__main__":
main() main()
......
...@@ -121,10 +121,10 @@ class cached(object): ...@@ -121,10 +121,10 @@ class cached(object):
# periodically save to prevent loss in case of system crash # periodically save to prevent loss in case of system crash
now = time.time() now = time.time()
if now - gvar.last_cache_save >= const.CacheSavePeriodInSec: if now - gvar.last_cache_save >= const.CacheSavePeriodInSec:
cached.savecache()
gvar.last_cache_save = now
if cached.debug: if cached.debug:
pdbg("Periodically saving Hash Cash") pdbg("Periodically saving Hash Cash")
cached.savecache()
gvar.last_cache_save = now
# merge the from 'fromc' cache into the 'to' cache. # merge the from 'fromc' cache into the 'to' cache.
# 'keepto': # 'keepto':
...@@ -197,7 +197,8 @@ class cached(object): ...@@ -197,7 +197,8 @@ class cached(object):
cached.cacheloaded = True cached.cacheloaded = True
if cached.verbose: if cached.verbose:
pr("Hash Cache File loaded.") pr("Hash Cache File loaded.")
except (EOFError, TypeError, ValueError) as ex: #except (EOFError, TypeError, ValueError, UnicodeDecodeError) as ex:
except Exception as ex:
perr("Fail to load the Hash Cache, no caching.\n{}".format(formatex(ex))) perr("Fail to load the Hash Cache, no caching.\n{}".format(formatex(ex)))
cached.cache = existingcache cached.cache = existingcache
else: else:
......
...@@ -12,7 +12,7 @@ import os ...@@ -12,7 +12,7 @@ import os
# https://packaging.python.org/single_source_version/ # https://packaging.python.org/single_source_version/
__title__ = 'bypy' __title__ = 'bypy'
__version__ = '1.6.0' __version__ = '1.6.1'
__author__ = 'Hou Tianze' __author__ = 'Hou Tianze'
__license__ = 'MIT' __license__ = 'MIT'
__desc__ = 'Python client for Baidu Yun (Personal Cloud Storage) 百度云/百度网盘 Python 客户端' __desc__ = 'Python client for Baidu Yun (Personal Cloud Storage) 百度云/百度网盘 Python 客户端'
......
{ {
"comment": "Update info", "comment": "Update info",
"recommendedVersion": "1.6.0", "recommendedVersion": "1.6.1",
"minimumRequiredVersion": "1.6.0" "minimumRequiredVersion": "1.6.1"
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册