File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
services/datalad/datalad_service/handlers Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 11import logging
22import os
33import pathlib
4+ import re
45import aioshutil
56
67import falcon
910from datalad_service .common .git import git_commit
1011from datalad_service .common .user import get_user_info
1112
13+ annex_key_re = re .compile (
14+ r'^(?P<backend>[A-Z0-9]+)-s(?P<size>[0-9]+)--(?P<hash>[a-f0-9]+)'
15+ )
16+
1217
1318async def move_files (upload_path , dataset_path ):
1419 for filename in pathlib .Path (upload_path ).glob ('**/*' ):
@@ -17,6 +22,17 @@ async def move_files(upload_path, dataset_path):
1722 dataset_path , os .path .relpath (filename , start = upload_path )
1823 )
1924 pathlib .Path (target ).parent .mkdir (parents = True , exist_ok = True )
25+ # Avoid reuploading dropped files
26+ if os .path .islink (target ):
27+ link_path = os .readlink (target )
28+ annex_key = os .path .basename (link_path )
29+ match = annex_key_re .match (annex_key )
30+ if match :
31+ key_size = int (match .group ('size' ))
32+ source_size = os .path .getsize (filename )
33+ if key_size == source_size :
34+ # This is the same size file, we can skip moving it
35+ continue
2036 await aioshutil .move (str (filename ), target )
2137
2238
You can’t perform that action at this time.
0 commit comments