diff --git a/bin/archiver.py b/bin/archiver.py index c3eba1d0..c0106c87 100755 --- a/bin/archiver.py +++ b/bin/archiver.py @@ -82,17 +82,17 @@ class Archiver(AbstractManager): uuid_file = capture_dir / 'uuid' if not uuid_file.exists(): self.logger.warning(f'No UUID file in {capture_dir}.') - shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures' / capture_dir.name)) + shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures')) continue with uuid_file.open() as _f: uuid = _f.read().strip() if not uuid: self.logger.warning(f'{uuid_file} is empty') - shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures' / capture_dir.name)) + shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures')) continue if uuid in current_index: self.logger.warning(f'Duplicate UUID ({uuid}) in {current_index[uuid]} and {uuid_file.parent.name}') - shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures' / capture_dir.name)) + shutil.move(str(capture_dir), str(get_homedir() / 'discarded_captures')) continue current_index[uuid] = uuid_file.parent.name @@ -188,7 +188,7 @@ class Archiver(AbstractManager): p.delete(str(capture_path)) (capture_path / 'tree.pickle').unlink(missing_ok=True) (capture_path / 'tree.pickle.gz').unlink(missing_ok=True) - shutil.move(str(capture_path), str(dest_dir / capture_path.name)) + shutil.move(str(capture_path), str(dest_dir)) p.execute() self.logger.info('Archiving done.') diff --git a/lookyloo/capturecache.py b/lookyloo/capturecache.py index 69e44a66..149ad57e 100644 --- a/lookyloo/capturecache.py +++ b/lookyloo/capturecache.py @@ -58,8 +58,6 @@ class CaptureCache(): self.logger = LookylooCacheLogAdapter(logger, {'uuid': self.uuid}) self.capture_dir: Path = Path(cache_entry['capture_dir']) - if not self.capture_dir.exists(): - raise MissingCaptureDirectory(f'The capture {self.uuid} does not exists in {self.capture_dir}.') if url := cache_entry.get('url'): # This entry *should* be present even if there is an error. @@ -95,6 +93,8 @@ class CaptureCache(): @property def tree(self) -> CrawledTree: + if not self.capture_dir.exists(): + raise MissingCaptureDirectory(f'The capture {self.uuid} does not exists in {self.capture_dir}.') return load_pickle_tree(self.capture_dir, self.capture_dir.stat().st_mtime, self.logger)