Skip to content

Commit

Permalink
fix uuid's not being unique
Browse files Browse the repository at this point in the history
  • Loading branch information
Dert1129 committed Nov 7, 2024
1 parent fb95e54 commit 1b95baf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions data_management/services/dlu_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def calculate_checksum(file_path: str):

class DLUFile:
def __init__(self, name: str, path: str, checksum: str, size: int, metadata: dict = {},
file_id: str = str(uuid.uuid4())):
file_id: str = None):
self.name = name
self.path = path
self.checksum = checksum
self.size = size
self.file_id = file_id
self.file_id = file_id or str(uuid.uuid4())
self.metadata = metadata

# Returns path without top directory, i.e. package dir or participant dir (bulk uploads)
Expand Down
9 changes: 5 additions & 4 deletions data_management/services/dlu_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ def update_dlu_package(self, package_id: str, fields_values: dict):
query = "UPDATE data_manager_data_v SET " + query_info["set_clause"] + " WHERE dlu_package_id = %s"
self.db.insert_data(query, values)

def insert_dlu_file(self, values):
def insert_dlu_file(self, dlu_fileName, dlu_package_id, dlu_file_id, dlu_filesize, dlu_md5checksum, dlu_metadata):
query = "INSERT INTO dlu_file (dlu_fileName, dlu_package_id, dlu_file_id, dlu_filesize, dlu_md5checksum, dlu_metadata) VALUES(%s, %s, %s, %s, %s, %s)"
self.db.insert_data(query, values)
return query % values
return self.db.insert_data(
query,
(dlu_fileName, dlu_package_id, dlu_file_id, dlu_filesize, dlu_md5checksum, dlu_metadata,),)

def insert_dlu_files(self, package_id: str, file_list: List[DLUFile]):
logger.info(f"Inserting files for package {package_id}")
for file in file_list:
query_string = self.insert_dlu_file((file.name, package_id, file.file_id, file.size, file.checksum, json.dumps(file.metadata)))
query_string = self.insert_dlu_file(file.name, package_id, file.file_id, file.size, file.checksum, json.dumps(file.metadata))
logger.info(query_string)

def get_ready_to_move(self, package_id: str):
Expand Down
2 changes: 1 addition & 1 deletion data_management/watch_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def move_packages_to_DLU(self, packages):
file_list = self.dlu_file_handler.match_files(top_level_subdir)
else:
file_list = self.dlu_file_handler.match_files(package_id)

self.dlu_file_handler.copy_files(package_id, self.process_file_paths(directory_info.file_details))
self.dlu_file_handler.chown_dir(package_id, file_list)
self.dlu_management.insert_dlu_files(package_id, file_list)
Expand Down

0 comments on commit 1b95baf

Please sign in to comment.