コード例 #1
0
ファイル: objectDatabaseV3.py プロジェクト: weijia/ufs
 def getFsObjFromUuid(self, objUuid):
     '''
     This will return the latest obj whose full path is specified by object with UUID=objUuid
     '''
     legacyObjInfo = self.getObjFromUuid(objUuid)
     fullPath = legacyObjInfo["fullPath"]
     obj = ufsObj.fsObj(fullPath, legacyObjInfo)
     #Check if the legacy object still exists
     if not obj.exists(fullPath):
         return None
     ncl('target obj:', legacyObjInfo)
     newObj = self.getFsObjFromFullPath(fullPath)
     return newObj
コード例 #2
0
ファイル: objectDatabaseV3.py プロジェクト: weijia/ufs
 def getFsObjFromFullPath(self, fullPath):
     '''
     Return object info with {"ufsUrl": "ufs://hostname/D:/tmp/xxx",
         "size": size, "timestamp": timestamp}
     '''
     objInFs = ufsObj.fsObj(fullPath)
     if objInFs.isContainer():
         res = self.getFsContainerObjFromFullPath(fullPath)
         ncl("returning: ", res["uuid"])
         return res
     ufsUrl = objInFs.getObjUfsUrl()
     if not objInFs.exists():
         ncl(fullPath)
         raise ObjectDoesNotExistInLocalFileSystem()
         return None
     for i in self.objDb.find({"ufsUrl": ufsUrl}).sort("timestamp", -1):
         #Check if the item is updated
         if objInFs["size"] == i["size"]:
             #Object size NOT changed
             if objInFs["timestamp"] == i["timestamp"]:
                 #Object size and time NOT changed, treated it as NOT changed.
                 del i["_id"]
                 ncl(i)
                 return ufsObj.ufsUrlObj(ufsUrl, i)
             if objInFs["headMd5"] == i["headMd5"]:
                 #The file is changed, but the content is not changed. Update the timestamp for the obj or add new item with new timestamp?
                 ncl('existing item as size and hash is the same, return existing info')
                 #Update the timestamp in the database as the item's timestamp in file system is different
                 self.objDb.find_and_modify({"uuid":i["uuid"]}, {"$set": {"timestamp":objInFs["timestamp"]}})
                 ncl("returnning: ", i["uuid"])
                 del i["_id"]
                 ncl(i)
                 return ufsObj.ufsUrlObj(ufsUrl, i)
     #The item is updated add the new item
     latestInfo = objInFs.getItemInfo()
     #objInFs["uuid"] = unicode(str(uuid.uuid4()))
     #objInFs["user"] = self.user
     objInFs["ufsUrl"] = ufsUrl
     #self.objDb.insert(objInFs.getItemInfo(), safe=True)
     #ncl('returning new obj')
     #print objInFs["uuid"]
     return self.insertObj(objInFs)