@@ -29,10 +29,6 @@ async def _delete_from_ipfs(self, file_hash: ItemHash):
29
29
result = await ipfs_client .pin .rm (file_hash )
30
30
print (result )
31
31
32
- # Launch the IPFS garbage collector (`ipfs repo gc`)
33
- async for _ in RepoAPI (driver = ipfs_client ).gc ():
34
- pass
35
-
36
32
except NotPinnedError :
37
33
LOGGER .warning ("File not pinned: %s" , file_hash )
38
34
except Exception as err :
@@ -73,6 +69,12 @@ async def collect(self, datetime: dt.datetime):
73
69
74
70
LOGGER .info ("Deleted %s" , file_hash )
75
71
72
+ # After unpinned all files call the ipfs garbage collector
73
+ ipfs_client = self .storage_service .ipfs_service .ipfs_client
74
+ # Launch the IPFS garbage collector (`ipfs repo gc`)
75
+ async for _ in RepoAPI (driver = ipfs_client ).gc ():
76
+ pass
77
+
76
78
77
79
async def garbage_collector_task (
78
80
config : Config , garbage_collector : GarbageCollector
@@ -93,5 +95,5 @@ async def garbage_collector_task(
93
95
LOGGER .info ("Starting garbage collection..." )
94
96
await garbage_collector .collect (datetime = utc_now ())
95
97
LOGGER .info ("Garbage collector ran successfully." )
96
- except Exception :
97
- LOGGER .exception ("An unexpected error occurred during garbage collection." )
98
+ except Exception as err :
99
+ LOGGER .exception ("An unexpected error occurred during garbage collection." , exc_info = err )
0 commit comments