Skip to content

Commit

Permalink
Merge pull request #50 from cecini/ensuremediadirexsit
Browse files Browse the repository at this point in the history
Ensure mediadir exsit in the case full sync from client should be ok after delete server collection dir
  • Loading branch information
VikashKothary authored Nov 16, 2020
2 parents bf0ad80 + 7a01c14 commit 1c64dc9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ankisyncd/sync_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,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

0 comments on commit 1c64dc9

Please sign in to comment.