Skip to content
Snippets Groups Projects
Commit 3cc345e7 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added symlink check to StorePreprocessor and ImportExecutor classes.

parent 404fcd8e
No related branches found
No related tags found
No related merge requests found
...@@ -93,7 +93,10 @@ class ImportExecutor(TaskExecutor): ...@@ -93,7 +93,10 @@ class ImportExecutor(TaskExecutor):
cnode.setAsyncTrans(True) cnode.setAsyncTrans(True)
cnode.setSticky(True) cnode.setSticky(True)
if self.dbConn.insertNode(cnode): if os.path.islink(dir):
now = dt.now()
nodeList.append([ now, dir, vospacePath, "container", "SYMLINK" ])
elif self.dbConn.insertNode(cnode):
now = dt.now() now = dt.now()
nodeList.append([ now, dir, vospacePath, "container", "DONE" ]) nodeList.append([ now, dir, vospacePath, "container", "DONE" ])
else: else:
...@@ -130,7 +133,10 @@ class ImportExecutor(TaskExecutor): ...@@ -130,7 +133,10 @@ class ImportExecutor(TaskExecutor):
dnode.setAsyncTrans(True) dnode.setAsyncTrans(True)
dnode.setSticky(True) dnode.setSticky(True)
if self.dbConn.insertNode(dnode): if os.path.islink(file):
now = dt.now()
nodeList.append([ now, file, vospacePath, "data", "SYMLINK" ])
elif self.dbConn.insertNode(dnode):
now = dt.now() now = dt.now()
nodeList.append([ now, file, vospacePath, "data", "DONE" ]) nodeList.append([ now, file, vospacePath, "data", "DONE" ])
else: else:
......
...@@ -113,26 +113,26 @@ class StorePreprocessor(TaskExecutor): ...@@ -113,26 +113,26 @@ class StorePreprocessor(TaskExecutor):
[ dirs, files ] = self.systemUtils.scanRecursive(self.path) [ dirs, files ] = self.systemUtils.scanRecursive(self.path)
# File catalog update # File catalog update
out = open("store_preprocessor_log.txt", "a") #out = open("store_preprocessor_log.txt", "a")
self.userId = self.dbConn.getUserId(self.username) self.userId = self.dbConn.getUserId(self.username)
out.write(f"USER: {self.username}\n") #out.write(f"USER: {self.username}\n")
out.write(f"USER_ID: {self.userId}\n") #out.write(f"USER_ID: {self.userId}\n")
pathPrefix = self.storageStorePath.replace("{username}", self.username) pathPrefix = self.storageStorePath.replace("{username}", self.username)
tstampWrapperDirPattern = re.compile("/[0-9]{4}_[0-9]{2}_[0-9]{2}-[0-9]{2}_[0-9]{2}_[0-9]{2}-vos_wrapper") tstampWrapperDirPattern = re.compile("/[0-9]{4}_[0-9]{2}_[0-9]{2}-[0-9]{2}_[0-9]{2}_[0-9]{2}-vos_wrapper")
for dir in dirs: for dir in dirs:
out.write(f"DIR: {dir}\n") #out.write(f"DIR: {dir}\n")
out.write(f"pathPrefix: {pathPrefix}\n") #out.write(f"pathPrefix: {pathPrefix}\n")
basePath = os.path.dirname(dir).replace(pathPrefix, "/" + self.username) basePath = os.path.dirname(dir).replace(pathPrefix, "/" + self.username)
out.write(f"basePath: {basePath}\n") #out.write(f"basePath: {basePath}\n")
nodeName = os.path.basename(dir) nodeName = os.path.basename(dir)
out.write(f"nodeName: {nodeName}\n") #out.write(f"nodeName: {nodeName}\n")
cnode = Node(nodeName, "container") cnode = Node(nodeName, "container")
if not tstampWrapperDirPattern.match("/" + nodeName): if not tstampWrapperDirPattern.match("/" + nodeName):
if tstampWrapperDirPattern.search(basePath): if tstampWrapperDirPattern.search(basePath):
tstampWrapperDir = tstampWrapperDirPattern.search(basePath).group(0).lstrip('/') tstampWrapperDir = tstampWrapperDirPattern.search(basePath).group(0).lstrip('/')
out.write(f"tstampWrapperDir: {tstampWrapperDir}\n") #out.write(f"tstampWrapperDir: {tstampWrapperDir}\n")
basePath = tstampWrapperDirPattern.sub("", basePath) basePath = tstampWrapperDirPattern.sub("", basePath)
out.write(f"newBasePath: {basePath}\n") #out.write(f"newBasePath: {basePath}\n")
cnode.setWrapperDir(tstampWrapperDir) cnode.setWrapperDir(tstampWrapperDir)
cnode.setParentPath(basePath) cnode.setParentPath(basePath)
locationId = self.dbConn.getLocationId(self.storageId) locationId = self.dbConn.getLocationId(self.storageId)
...@@ -142,26 +142,32 @@ class StorePreprocessor(TaskExecutor): ...@@ -142,26 +142,32 @@ class StorePreprocessor(TaskExecutor):
cnode.setContentLength(0) cnode.setContentLength(0)
cnode.setSticky(True) cnode.setSticky(True)
if self.dbConn.insertNode(cnode): if os.path.islink(dir):
# node is a symlink, do not import it...
pass
elif self.dbConn.insertNode(cnode):
self.nodeList.append(basePath + '/' + nodeName) self.nodeList.append(basePath + '/' + nodeName)
else:
# node already exists, skip it...
pass
out.write("\n\n") #out.write("\n\n")
for flist in files: for flist in files:
for file in flist: for file in flist:
out.write(f"FILE: {file}\n") #out.write(f"FILE: {file}\n")
if self.md5calc.fileIsValid(file): if self.md5calc.fileIsValid(file):
out.write(f"pathPrefix: {pathPrefix}\n") #out.write(f"pathPrefix: {pathPrefix}\n")
basePath = os.path.dirname(file).replace(pathPrefix, "/" + self.username) basePath = os.path.dirname(file).replace(pathPrefix, "/" + self.username)
out.write(f"basePath: {basePath}\n") #out.write(f"basePath: {basePath}\n")
nodeName = os.path.basename(file) nodeName = os.path.basename(file)
out.write(f"nodeName: {nodeName}\n") #out.write(f"nodeName: {nodeName}\n")
dnode = Node(nodeName, "data") dnode = Node(nodeName, "data")
if tstampWrapperDirPattern.search(basePath): if tstampWrapperDirPattern.search(basePath):
tstampWrapperDir = tstampWrapperDirPattern.search(basePath).group(0).lstrip('/') tstampWrapperDir = tstampWrapperDirPattern.search(basePath).group(0).lstrip('/')
out.write(f"tstampWrapperDir: {tstampWrapperDir}\n") #out.write(f"tstampWrapperDir: {tstampWrapperDir}\n")
basePath = tstampWrapperDirPattern.sub("", basePath) basePath = tstampWrapperDirPattern.sub("", basePath)
out.write(f"newBasePath: {basePath}\n") #out.write(f"newBasePath: {basePath}\n")
dnode.setWrapperDir(tstampWrapperDir) dnode.setWrapperDir(tstampWrapperDir)
dnode.setParentPath(basePath) dnode.setParentPath(basePath)
locationId = self.dbConn.getLocationId(self.storageId) locationId = self.dbConn.getLocationId(self.storageId)
...@@ -172,11 +178,17 @@ class StorePreprocessor(TaskExecutor): ...@@ -172,11 +178,17 @@ class StorePreprocessor(TaskExecutor):
dnode.setContentMD5(self.md5calc.getMD5(file)) dnode.setContentMD5(self.md5calc.getMD5(file))
dnode.setSticky(True) dnode.setSticky(True)
if self.dbConn.insertNode(dnode): if os.path.islink(file):
# node is a symlink, do not import it...
pass
elif self.dbConn.insertNode(dnode):
self.nodeList.append(basePath + '/' + nodeName) self.nodeList.append(basePath + '/' + nodeName)
else:
# node already exists, skip it...
pass
out.write("\n") #out.write("\n")
out.close() #out.close()
def update(self): def update(self):
self.jobObj.setPhase("QUEUED") self.jobObj.setPhase("QUEUED")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment