Commit ed4212a5 authored by Julian Rother's avatar Julian Rother
Browse files

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

parent cfdef0f8
...@@ -13,12 +13,13 @@ def on_file_received(handler, path): ...@@ -13,12 +13,13 @@ def on_file_received(handler, path):
elif path.startswith(RAW_TMP): elif path.startswith(RAW_TMP):
path = path[len(RAW_TMP):].lstrip('/') path = path[len(RAW_TMP):].lstrip('/')
num = 0 num = 0
suffix = '' rpath = path
while os.path.exists(RAW_TARGET+'/'+path+suffix): while os.path.exists(RAW_TARGET+'/'+rpath):
num += 1 num += 1
suffix = '.'+str(num) p = path.rsplit('.', 1)
os.rename(RAW_TMP+'/'+path, RAW_TARGET+'/'+path+suffix) rpath = '.'.join([p[0]+'_'+str(num)]+p[1:])
requests.get(API_BASEURL+'/internal/sort/autoencode', params={'apikey': API_APIKEY, 'path': path+suffix}) os.rename(RAW_TMP+'/'+path, RAW_TARGET+'/'+rpath)
requests.get(API_BASEURL+'/internal/sort/autoencode', params={'apikey': API_APIKEY, 'path': rpath})
else: else:
print("Unknown path:", path) 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