Skip to content

Commit

Permalink
- Close #437: Ensure cache loading/saving failures won't affect norma…
Browse files Browse the repository at this point in the history
…l operations

- Fix the bug that clean up code not called on exit
- Version bump
  • Loading branch information
houtianze committed Mar 21, 2018
1 parent 206c1c7 commit 950d891
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 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.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)
Expand Down
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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.5.13: Fix multiprocess upload/syncup missing some files
- 1.5.12: Add one more heroku server; Workaround "ValueError: unknown
Expand Down
10 changes: 7 additions & 3 deletions bypy/bypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ def __init__(self,
# so if any code using this class can check the current verbose / debug level
cached.verbose = self.verbose = verbose
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
# I give up and disable it for good, or for bad
Expand Down Expand Up @@ -491,7 +493,7 @@ def __init__(self,
"minimum required version is {}.\n"
"Please run 'pip install -U bypy' to update and try again.".format(
const.__version__, minver))
quit(const.EUpdateNeeded)
self.quit(const.EUpdateNeeded)
else:
self.__setting[const.SettingKey_LastUpdateCheckTime] = nowsec
self.savesetting()
Expand Down Expand Up @@ -3561,6 +3563,7 @@ def clean_prog_files(cleanlevel, verbose, configdir = const.ConfigDir):
def main(argv=None): # IGNORE:C0111
''' Main Entry '''

by = None
reqres = check_requirements()
if reqres == CheckResult.Error:
perr("Requirement checking failed")
Expand Down Expand Up @@ -3687,8 +3690,9 @@ def main(argv=None): # IGNORE:C0111
perr("Exception occurred:\n{}".format(formatex(ex)))
pr("Abort")
raise

quit(result)
finally:
if by:
by.quit(result)

if __name__ == "__main__":
main()
Expand Down
7 changes: 4 additions & 3 deletions bypy/cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def __store(self, info, path, value):
# periodically save to prevent loss in case of system crash
now = time.time()
if now - gvar.last_cache_save >= const.CacheSavePeriodInSec:
if cached.debug:
pdbg("Periodically saving Hash Cash")
cached.savecache()
gvar.last_cache_save = now
if cached.debug:
pdbg("Periodically saving Hash Cash")

# merge the from 'fromc' cache into the 'to' cache.
# 'keepto':
Expand Down Expand Up @@ -197,7 +197,8 @@ def loadcache(existingcache = {}):
cached.cacheloaded = True
if cached.verbose:
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)))
cached.cache = existingcache
else:
Expand Down
2 changes: 1 addition & 1 deletion bypy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# https://packaging.python.org/single_source_version/
__title__ = 'bypy'
__version__ = '1.6.0'
__version__ = '1.6.1'
__author__ = 'Hou Tianze'
__license__ = 'MIT'
__desc__ = 'Python client for Baidu Yun (Personal Cloud Storage) 百度云/百度网盘 Python 客户端'
Expand Down
4 changes: 2 additions & 2 deletions update/update.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"comment": "Update info",
"recommendedVersion": "1.6.0",
"minimumRequiredVersion": "1.6.0"
"recommendedVersion": "1.6.1",
"minimumRequiredVersion": "1.6.1"
}

0 comments on commit 950d891

Please sign in to comment.