Skip to content
Snippets Groups Projects

ENH: treat case of removed files

Merged Henrik tom Wörden requested to merge f-move into dev
All threads resolved!
@@ -62,15 +62,28 @@ def rename(changes, chunksize=10):
continue
cont = db.Container()
for _, (old, new) in chunk.iterrows():
cont.append(db.File(path=old))
cont.retrieve()
for fi, (_, (old, new)) in zip(cont, chunk.iterrows()):
assert fi.path == old
fi.path = new
cont.update()
cmap = {}
for ii, (old, new) in chunk.iterrows():
try:
fi = db.File(path=old)
fi.retrieve()
if not fi.is_valid():
continue
cont.append(fi)
cmap[ii] = len(cont)-1
except Exception as e:
print(e)
for ii, (old, new) in chunk.iterrows():
if ii not in cmap:
continue
assert cont[cmap[ii]].path == old
cont[cmap[ii]].path = new
if len(cont) > 0:
cont.update(unique=False)
i += 1
Loading