예제 #1
0
파일: temp27.py 프로젝트: swgeek/dbcode
def checkBackupDb(dirlist, backupDbPath, db, logger):
    backupDb = CoreDb.CoreDb(backupDbPath)

    logger.log("checking %s" % backupDbPath)
    for dirhash in dirlist:
        dirpath = miscQueries.getDirectoryPath(backupDb, dirhash)
        if dirpath:
            logger.log("found %s: " % dirhash)
            logger.log(dirpath)
            miscQueries.insertDirHash(db, dirhash, dirpath)
예제 #2
0
def insertAncestorDirsIntoDb(db, dirpathDict, dirpath, logger):
    ancestorDirs = getAncestorPaths(dirpath)

    for dirpathToAdd in ancestorDirs:
        dirhash = Sha1HashUtilities.HashString(dirpathToAdd)
        if dirpathDict.get(dirhash):
            # already in db, no need to add
            continue

        # not in db, add
        dirpathDict[dirhash] = dirpathToAdd
        miscQueries.insertDirHash(db, dirhash, dirpathToAdd)
예제 #3
0
count = 0

depotRootPath = "E:\\objectstore2"
for filehash, dirpath, filename in filehashAndPathList:
    count += 1
    logger.log("%d: %s:%s:%s" % (count, filehash, dirpath, filename))

    filestatus = "notFound"
    fileInfo = miscQueries.getFileInfo(db, filehash)
    if fileInfo:
        filestatus = fileInfo[3]

    if filestatus == "notFound":
        logger.log("\tcopying file into depot")
        filepath = os.path.join(dirpath, filename)
        FileUtils.CopyFileIntoDepot(depotRootPath, filepath, filehash, logger)
        if not fileInfo:
            filesize = os.path.getsize(filepath)
            logger.log("adding to files table")
            miscQueries.insertFileEntry(db, filehash, filesize, 1)

    newDirPath = dirpath.replace("F:", "D:")
    dirhash = Sha1HashUtilities.HashString(newDirPath)
    if not miscQueries.checkIfDirhashInDatabase(db, dirhash):
        logger.log("\tnew dir path %s" % newDirPath)
        miscQueries.insertDirHash(db, dirhash, newDirPath)

    if not miscQueries.checkIfFileDirectoryInDatabase(db, filehash, filename,
                                                      dirhash):
        miscQueries.insertOriginalDir(db, filehash, filename, dirhash)
예제 #4
0
logger.log("got: %d files" % len(filesToAdd))

# add directories to database
allDirs = set()
for filename, dirpath, filehash in filesToAdd:
	allDirs.add(dirpath)

for dirpath in allDirs:
	logger.log("inserting directory %s" % dirpath)
	dirhash = Sha1HashUtilities.HashString(dirpath).upper()
	if miscQueries.checkIfDirhashInDatabase(db, dirhash):
		logger.log(" dir %s already in database, not adding" % dirpath)
		dirsAlreadyInDb += 1
	else:
		logger.log(" inserting dir %s" % dirpath)
		miscQueries.insertDirHash(db, dirhash, dirpath)
		dirsAddedToDb += 1


for filename, dirpath, filehash in filesToAdd:
	logger.log("adding file: %s, %s, %s" % (filename, dirpath, filehash))

	filepath = os.path.join(dirpath, filename)
	filehash = filehash.upper()

	# if file not already in depot/database, insert
	if miscQueries.checkIfFilehashInDatabase(db, filehash):
		logger.log("already in database")
		filesAlreadyInDb += 1
	else:
		logger.log("not in database, need to add")
예제 #5
0
def addEntryToOriginalDirsTable(db, dirhash, dirpath):
    if not miscQueries.checkIfDirhashInDatabase(db, dirhash):
        logger.log(" inserting dir %s" % dirpath)
        miscQueries.insertDirHash(db, dirhash, dirpath)