diff --git a/b2mirror/mirror.py b/b2mirror/mirror.py index 2108160..43887ca 100644 --- a/b2mirror/mirror.py +++ b/b2mirror/mirror.py @@ -12,7 +12,6 @@ from b2mirror.common import Result, results_ok # import logging # logging.basicConfig(level=logging.INFO) - """ How it works: @@ -79,7 +78,7 @@ class B2SyncManager(object): tables = { "files": """ CREATE TABLE `files` ( - `path` varchar(1024) PRIMARY KEY, + `path` varchar(4096) PRIMARY KEY, `mtime` INTEGER, `size` INTEGER, `seen` BOOLEAN @@ -141,6 +140,7 @@ class B2SyncManager(object): Future-called function that handles a single file. The file's modification time is checked against the database to see if the file has new content that should be uploaded or is untouched since the last sync """ + result = Result.failed c = self.db.cursor() @@ -149,9 +149,6 @@ class B2SyncManager(object): if self.should_transfer(row, f): - # The file was uploaded, commit it to the db - c.execute("REPLACE INTO 'files' VALUES(?, ?, ?, ?);", (f.rel_path, f.mtime, f.size, 1)) - print("Uploading:", f.rel_path) try: result = self.dest.put_file(f, purge_historics=row is not None) @@ -160,6 +157,9 @@ class B2SyncManager(object): print("Unexpected error:", sys.exc_info()[0]) raise + # The file was uploaded, commit it to the db + c.execute("REPLACE INTO 'files' VALUES(?, ?, ?, ?);", (f.rel_path, f.mtime, f.size, 1)) + else: c.execute("UPDATE 'files' SET seen=1 WHERE `path` = ?;", (f.rel_path,)).fetchone() #print("Skipping:", f.rel_path) diff --git a/bin/b2mirror b/bin/b2mirror index 6a10d47..1d66c62 100755 --- a/bin/b2mirror +++ b/bin/b2mirror @@ -22,7 +22,7 @@ def main(): args = parser.parse_args() - ignore_res = [re.compile(i) for i in args.exclude] + ignore_res = [re.compile(i) for i in args.exclude] if args.exclude else [] mirror.sync( args.source,