Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to support slack-export-viewer #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 52 additions & 3 deletions wayslack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down