Commit ed4212a5 authored by Julian Rother's avatar Julian Rother

Fixed handling of duplicate file names in autoencoding (closes #1)

parent cfdef0f8
......@@ -13,12 +13,13 @@ def on_file_received(handler, path):
elif path.startswith(RAW_TMP):
path = path[len(RAW_TMP):].lstrip('/')
num = 0
suffix = ''
while os.path.exists(RAW_TARGET+'/'+path+suffix):
rpath = path
while os.path.exists(RAW_TARGET+'/'+rpath):
num += 1
suffix = '.'+str(num)
os.rename(RAW_TMP+'/'+path, RAW_TARGET+'/'+path+suffix)
requests.get(API_BASEURL+'/internal/sort/autoencode', params={'apikey': API_APIKEY, 'path': path+suffix})
p = path.rsplit('.', 1)
rpath = '.'.join([p[0]+'_'+str(num)]+p[1:])
os.rename(RAW_TMP+'/'+path, RAW_TARGET+'/'+rpath)
requests.get(API_BASEURL+'/internal/sort/autoencode', params={'apikey': API_APIKEY, 'path': rpath})
else:
print("Unknown path:", path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment