Skip to content

Commit fadca0f

Browse files
author
Andres D. Molins
committed
Fix: Move IPFS Garbage collection call to final step.
1 parent c6ecbfa commit fadca0f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/aleph/services/storage/garbage_collector.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ async def _delete_from_ipfs(self, file_hash: ItemHash):
2929
result = await ipfs_client.pin.rm(file_hash)
3030
print(result)
3131

32-
# Launch the IPFS garbage collector (`ipfs repo gc`)
33-
async for _ in RepoAPI(driver=ipfs_client).gc():
34-
pass
35-
3632
except NotPinnedError:
3733
LOGGER.warning("File not pinned: %s", file_hash)
3834
except Exception as err:
@@ -73,6 +69,12 @@ async def collect(self, datetime: dt.datetime):
7369

7470
LOGGER.info("Deleted %s", file_hash)
7571

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+
7678

7779
async def garbage_collector_task(
7880
config: Config, garbage_collector: GarbageCollector
@@ -93,5 +95,5 @@ async def garbage_collector_task(
9395
LOGGER.info("Starting garbage collection...")
9496
await garbage_collector.collect(datetime=utc_now())
9597
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

Comments
 (0)