Loading transfer_service/checksum.py +17 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,23 @@ class Checksum(object): def setFileBufferSize(fileBufferSize): self.fileBufferSize = fileBufferSize def fileIsValid(self, absFilePath): if not self.md5FileSuffix in absFilePath: return True else: return False def getMD5(self, absFilePath): if self.fileIsValid(absFilePath): md5FileName = os.path.dirname(absFilePath) + self.md5FileSuffix md5File = open(md5FileName, "r") for row in md5File: md5sum = row.split(" ./")[0] fileName = row.split(" ./")[1].rstrip() if fileName == os.path.basename(absFilePath): return md5sum return None def md5sum(self, filePath): md5Hash = hashlib.md5() with open(filePath, "rb") as f: Loading transfer_service/db_connector.py +2 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,8 @@ class DbConnector(object): self.cursor.execute("SELECT get_ltree_path(%s)", (parentOSPath,)) parentLtreePath = self.cursor.fetchone()[0] #print(f"parentLtreePath: {parentLtreePath}, type: {type(parentLtreePath)}") self.cursor.execute("INSERT INTO Node(parent_path, name, type, owner_id, creator_id) VALUES (%s, %s, %s, %s, %s);", (parentLtreePath, node.name, node.type, node.ownerID, node.creatorID)) self.cursor.execute("INSERT INTO Node(parent_path, name, type, owner_id, creator_id, content_md5) VALUES (%s, %s, %s, %s, %s, %s);", (parentLtreePath, node.name, node.type, node.ownerID, node.creatorID, node.contentMD5,)) self.conn.commit() def selectNode(self): Loading transfer_service/store_preprocessor.py +7 −5 Original line number Diff line number Diff line Loading @@ -134,10 +134,12 @@ class StorePreprocessor(object): for flist in files: for file in flist: print(f"FILE: {file}") if self.md5calc.fileIsValid(file): dnode = Node(os.path.basename(file), "data") dnode.setParentPath(os.path.dirname(file)) dnode.setOwnerID("3354") dnode.setCreatorID("3354") dnode.setContentMD5(self.md5calc.getMD5(file)) self.dbConn.insertNode(dnode, dnode.parentPath) self.dbConn.disconnect() Loading Loading
transfer_service/checksum.py +17 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,23 @@ class Checksum(object): def setFileBufferSize(fileBufferSize): self.fileBufferSize = fileBufferSize def fileIsValid(self, absFilePath): if not self.md5FileSuffix in absFilePath: return True else: return False def getMD5(self, absFilePath): if self.fileIsValid(absFilePath): md5FileName = os.path.dirname(absFilePath) + self.md5FileSuffix md5File = open(md5FileName, "r") for row in md5File: md5sum = row.split(" ./")[0] fileName = row.split(" ./")[1].rstrip() if fileName == os.path.basename(absFilePath): return md5sum return None def md5sum(self, filePath): md5Hash = hashlib.md5() with open(filePath, "rb") as f: Loading
transfer_service/db_connector.py +2 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,8 @@ class DbConnector(object): self.cursor.execute("SELECT get_ltree_path(%s)", (parentOSPath,)) parentLtreePath = self.cursor.fetchone()[0] #print(f"parentLtreePath: {parentLtreePath}, type: {type(parentLtreePath)}") self.cursor.execute("INSERT INTO Node(parent_path, name, type, owner_id, creator_id) VALUES (%s, %s, %s, %s, %s);", (parentLtreePath, node.name, node.type, node.ownerID, node.creatorID)) self.cursor.execute("INSERT INTO Node(parent_path, name, type, owner_id, creator_id, content_md5) VALUES (%s, %s, %s, %s, %s, %s);", (parentLtreePath, node.name, node.type, node.ownerID, node.creatorID, node.contentMD5,)) self.conn.commit() def selectNode(self): Loading
transfer_service/store_preprocessor.py +7 −5 Original line number Diff line number Diff line Loading @@ -134,10 +134,12 @@ class StorePreprocessor(object): for flist in files: for file in flist: print(f"FILE: {file}") if self.md5calc.fileIsValid(file): dnode = Node(os.path.basename(file), "data") dnode.setParentPath(os.path.dirname(file)) dnode.setOwnerID("3354") dnode.setCreatorID("3354") dnode.setContentMD5(self.md5calc.getMD5(file)) self.dbConn.insertNode(dnode, dnode.parentPath) self.dbConn.disconnect() Loading