diff --git a/wayslack.py b/wayslack.py index 69063ff..566c61c 100755 --- a/wayslack.py +++ b/wayslack.py @@ -379,10 +379,13 @@ def _downloader(self, item): for chunk in res.iter_content(4096): hash.update(chunk) f.write(chunk) - if hash.hexdigest() != res.headers["etag"].strip('"'): - raise Exception("Downloading %r: checksum does not match. etag %r != md5 %r\n" %( + etag = res.headers.get("etag") + if etag: + etag = etag.strip('"') + if etag and hash.hexdigest() != etag: + print("Downloading %r: checksum does not match. etag %r != md5 %r\n" %( url, - res.headers["etag"], + etag, hash.hexdigest(), )) self.counter += 1 @@ -672,10 +675,56 @@ def refresh(self): class ArchiveGroups(BaseArchiver): name = "groups" + def _fixup_symlinks(self): + for chan in self.get_list(): + chan_name_dir = self.archive.path / to_str(chan.name) + if chan_name_dir.exists(): + continue + if chan_name_dir.is_symlink(): + chan_name_dir.unlink() + symlink_target = os.path.relpath( + str(chan.path), + str(chan_name_dir.parent), + ) + chan_name_dir.symlink_to(symlink_target) + + archive_channels = self.archive.path / "mpims.json" + if not archive_channels.exists(): + if archive_channels.is_symlink(): + archive_channels.unlink() + archive_channels.symlink_to("_private/default/_groups/groups.json") + + def refresh(self): + BaseArchiver.refresh(self) + self._fixup_symlinks() + class ArchiveIMs(BaseArchiver): name = "ims" + def _fixup_symlinks(self): + for chan in self.get_list(): + chan_name_dir = self.archive.path / to_str(chan.id) + if chan_name_dir.exists(): + continue + if chan_name_dir.is_symlink(): + chan_name_dir.unlink() + symlink_target = os.path.relpath( + str(chan.path), + str(chan_name_dir.parent), + ) + chan_name_dir.symlink_to(symlink_target) + + archive_channels = self.archive.path / "dms.json" + if not archive_channels.exists(): + if archive_channels.is_symlink(): + archive_channels.unlink() + archive_channels.symlink_to("_private/default/_ims/ims.json") + + def refresh(self): + BaseArchiver.refresh(self) + self._fixup_symlinks() + class ArchiveUsers(BaseArchiver): name = "users"