warn about subfolders

This commit is contained in:
Damien Elmes 2017-08-28 22:01:13 +10:00
parent 226bb2bc83
commit 3faa82571c
2 changed files with 11 additions and 6 deletions

View file

@ -259,16 +259,18 @@ create table meta (dirMod int, lastUsn int); insert into meta values (0, 0);
allRefs.update(noteRefs) allRefs.update(noteRefs)
# loop through media folder # loop through media folder
unused = [] unused = []
invalid = []
if local is None: if local is None:
files = os.listdir(mdir) files = os.listdir(mdir)
else: else:
files = local files = local
renamedFiles = False renamedFiles = False
dirFound = False
warnings = []
for file in files: for file in files:
if not local: if not local:
if not os.path.isfile(file): if not os.path.isfile(file):
# ignore directories # ignore directories
dirFound = True
continue continue
if file.startswith("_"): if file.startswith("_"):
# leading _ says to ignore file # leading _ says to ignore file
@ -301,7 +303,11 @@ create table meta (dirMod int, lastUsn int); insert into meta values (0, 0);
self.findChanges() self.findChanges()
except DBError: except DBError:
self._deleteDB() self._deleteDB()
return (nohave, unused, invalid)
if dirFound:
warnings.append(
_("Anki does not support files in subfolders of the collection.media folder."))
return (nohave, unused, warnings)
def _normalizeNoteRefs(self, nid): def _normalizeNoteRefs(self, nid):
note = self.col.getNote(nid) note = self.col.getNote(nid)

View file

@ -975,13 +975,12 @@ will be lost. Continue?"""))
def onCheckMediaDB(self): def onCheckMediaDB(self):
self.progress.start(immediate=True) self.progress.start(immediate=True)
(nohave, unused, invalid) = self.col.media.check() (nohave, unused, warnings) = self.col.media.check()
self.progress.finish() self.progress.finish()
# generate report # generate report
report = "" report = ""
if invalid: if warnings:
report += _("Invalid encoding; please rename:") report += "\n".join(warnings) + "\n"
report += "\n" + "\n".join(invalid)
if unused: if unused:
if report: if report:
report += "\n\n\n" report += "\n\n\n"