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

Ensure mediadir exsit in the case full sync from client should be ok after delete server collection dir #50

Merged
merged 1 commit into from
Nov 16, 2020
Merged
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
5 changes: 4 additions & 1 deletion src/ankisyncd/sync_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,17 @@ def _adopt_media_changes_from_zip(self, zip_file):
media_to_add = []
usn = self.col.media.lastUsn()
oldUsn = usn
media_dir = self.col.media.dir()
os.makedirs(media_dir, exist_ok=True)

for i in zip_file.infolist():
if i.filename == "_meta": # Ignore previously retrieved metadata.
continue

file_data = zip_file.read(i)
csum = anki.utils.checksum(file_data)
filename = self._normalize_filename(meta[int(i.filename)][0])
file_path = os.path.join(self.col.media.dir(), filename)
file_path = os.path.join(media_dir, filename)

# Save file to media directory.
with open(file_path, 'wb') as f:
Expand Down