Adam Watkins <[email protected]> writes:
> Applied the patch, and ran it a few times.
>
> I've attached a log where the NoneType does *not* happen (22.07.30)
> and a log where it *does* (22.13.02), in the off-chance that'll help.

Thanks! I think I figured out what's happening here. It does not have
any adverse effects other than the longer error message, but I'd still
like to fix it.

Could you try the attached patch and confirm that the 'NoneType' error
no longer occurs?

Thanks!
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«

-- 
You received this message because you are subscribed to the Google Groups 
"s3ql" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/s3ql/adm.py b/src/s3ql/adm.py
--- a/src/s3ql/adm.py
+++ b/src/s3ql/adm.py
@@ -92,7 +92,7 @@
 
     if options.action == 'upgrade':
         return upgrade(options)
-    
+
     with get_backend(options) as backend:
         if options.action == 'passphrase':
             return change_passphrase(backend)
@@ -375,9 +375,7 @@
               '---END MASTER KEY---',
               sep='\n')
 
-@handle_on_return
-def update_obj_metadata(backend, backend_factory, db,
-                        thread_count, on_return):
+def update_obj_metadata(backend, backend_factory, db, thread_count):
     '''Upgrade metadata of storage objects'''
 
     plain_backend = backend.backend
@@ -406,7 +404,7 @@
     queue = Queue(maxsize=thread_count)
     threads = []
     for _ in range(thread_count):
-        t = AsyncFn(upgrade_loop, queue, on_return.push(backend_factory()))
+        t = AsyncFn(upgrade_loop, queue, backend_factory)
         # Don't wait for worker threads, gives deadlock if main thread
         # terminates with exception
         t.daemon = True
@@ -453,38 +451,39 @@
 
     sys.stdout.write('\n')
 
-def upgrade_loop(queue, backend):
-    plain_backend = backend.backend
+def upgrade_loop(queue, backend_factory):
 
-    while True:
-        obj_id = queue.get()
-        if obj_id is None:
-            break
+    with backend_factory() as backend:
+        plain_backend = backend.backend
+        while True:
+            obj_id = queue.get()
+            if obj_id is None:
+                break
 
-        meta = plain_backend.lookup(obj_id)
-        if meta.get('format_version', 0) == 2:
-            continue
+            meta = plain_backend.lookup(obj_id)
+            if meta.get('format_version', 0) == 2:
+                continue
 
-        # For important objects, we make a copy first (just to be safe)
-        if not obj_id.startswith('s3ql_data'):
-            plain_backend.copy(obj_id, 's3ql_pre2.13' + obj_id[4:])
+            # For important objects, we make a copy first (just to be safe)
+            if not obj_id.startswith('s3ql_data'):
+                plain_backend.copy(obj_id, 's3ql_pre2.13' + obj_id[4:])
 
-        # When reading passphrase objects, we have to use the
-        # "outer" password
-        if obj_id.startswith('s3ql_passphrase'):
-            data_pw = backend.passphrase
-            backend.passphrase = backend.fs_passphrase
+            # When reading passphrase objects, we have to use the
+            # "outer" password
+            if obj_id.startswith('s3ql_passphrase'):
+                data_pw = backend.passphrase
+                backend.passphrase = backend.fs_passphrase
 
-        meta = backend._convert_legacy_metadata(meta)
-        if meta['encryption'] == 'AES':
-            # Two statements to reduce likelihood of update races
-            size = rewrite_legacy_object(backend, obj_id)
-            queue.rewrote_size += size
-        else:
-            plain_backend.update_meta(obj_id, meta)
+            meta = backend._convert_legacy_metadata(meta)
+            if meta['encryption'] == 'AES':
+                # Two statements to reduce likelihood of update races
+                size = rewrite_legacy_object(backend, obj_id)
+                queue.rewrote_size += size
+            else:
+                plain_backend.update_meta(obj_id, meta)
 
-        if obj_id.startswith('s3ql_passphrase'):
-            backend.passphrase = data_pw
+            if obj_id.startswith('s3ql_passphrase'):
+                backend.passphrase = data_pw
 
 def rewrite_legacy_object(backend, obj_id):
     with tempfile.TemporaryFile() as tmpfh:

Reply via email to