handle new version of file with old one moved to versions
This commit is contained in:
parent
39b5065b59
commit
52b524430c
1 changed files with 3 additions and 1 deletions
|
@ -78,13 +78,15 @@ def update_files(user, volume, files):
|
||||||
for f in files:
|
for f in files:
|
||||||
if len(f['path'].split('/')) == folder_depth:
|
if len(f['path'].split('/')) == folder_depth:
|
||||||
all_files.append(f['oshash'])
|
all_files.append(f['oshash'])
|
||||||
update_or_create_instance(volume, f)
|
|
||||||
|
|
||||||
#remove deleted files
|
#remove deleted files
|
||||||
removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
|
removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
|
||||||
ids = [i['itemId'] for i in Item.objects.filter(
|
ids = [i['itemId'] for i in Item.objects.filter(
|
||||||
files__instances__in=removed.filter(file__selected=True)).distinct().values('itemId')]
|
files__instances__in=removed.filter(file__selected=True)).distinct().values('itemId')]
|
||||||
removed.delete()
|
removed.delete()
|
||||||
|
for f in files:
|
||||||
|
if f['oshash'] in all_files:
|
||||||
|
update_or_create_instance(volume, f)
|
||||||
for i in ids:
|
for i in ids:
|
||||||
i = Item.objects.get(itemId=i)
|
i = Item.objects.get(itemId=i)
|
||||||
i.update_selected()
|
i.update_selected()
|
||||||
|
|
Loading…
Reference in a new issue