From d16226c8798162f45be4f7dc89546fe1e86c3f9a Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 6 Oct 2022 21:55:31 +0300 Subject: [PATCH] bug patch for duplicate SUrvexFile object --- core/views/uploads.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/views/uploads.py b/core/views/uploads.py index 2aff64b..7c5406f 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -171,8 +171,14 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl): try: sxpath = str(Path(sx).with_suffix('')) svxfile = SurvexFile.objects.get(path=sxpath) + except MultipleObjectsReturned: + # can happen if connecting a wallet to a survex file.. i think.. + svxfiles = SurvexFile.objects.filter(path=sxpath) + for s in svxfiles: + print(s.path, s.cave, s.survexdirectory) + svxfile = svxfiles[0] # dont' know how this happened, fix later.. except: - file_complaint = f"{wallet} Survex file {sx} exists, but is not registered as imported via a *include {sxpath}." + file_complaint = f"{wallet} Survex file {sx} exists, but is not registered in the database {sxpath}. How?.." complaints.append(file_complaint) message = f"! {file_complaint}" print(message) @@ -964,3 +970,4 @@ def dwgupload(request, folder=None, gitdisable='no'): return render(request, 'dwguploadform.html', {'form': form, 'doesnotexist': doesnotexist, 'urlfile': urlfile, 'urldir': urldir,'folder': folder, 'files': files, 'dirs': dirs, 'filesaved': filesaved, 'actual_saved': actual_saved, 'refused': refused}) +