예제 #1
0
def insertToSubLibrary(savePath, fileType, filePath, remarks):
    modifyTime = os.path.getmtime(filePath)
    group = time.strftime('%Y-%m', time.localtime(modifyTime))
    size = os.path.getsize(filePath)
    ret = SqliteFunc.tableInsert(SqliteFunc.TB_CACHE, ['fileType', 'url', 'folder', 'name', 'lastModify', 'contentLength', \
                                'remarks', 'groupTime'], (fileType, filePath.replace('\\','/'), os.path.dirname(filePath), \
                                os.path.basename(filePath), modifyTime, size, remarks, group, ), True)
예제 #2
0
def addShare(shareId, location, url, name, ext, isdir, access, validity, size):
    global _shareMutex
    _shareMutex.acquire()
    try:
        location = location.decode('utf-8')
        name = name.decode('utf-8')
    except:
        pass
    #ret = execSharesSql('select * from shares where shareId=?', (shareId,))
    ret = SqliteFunc.tableSelect(SqliteFunc.TB_SHARES, [], 'shareId=?', (shareId,))
    if not ret or len(ret) == 0:
        #ret = execSharesSql('insert into shares(shareId, location, url, name, contentType, isFolder, extractionCode, validity, contentlength, lastModify) values(?,?,?,?,?,?,?,?,?,?)', (shareId, location, url, name, ext, isdir, access, validity, size, UtilFunc.Now()))
        ret = SqliteFunc.tableInsert(SqliteFunc.TB_SHARES, ['shareId', 'location', 'url', 'name', 'contentType', 'isFolder', 'extractionCode', 'validity', 'contentlength', 'lastModify'],\
                                      (shareId, location, url, name, ext, isdir, access, validity, size, UtilFunc.Now(),))  
    else:
        #ret = execSharesSql('update shares set location=?, url=?, name=?, contentType=?, isFolder=?, extractionCode=?, validity=?, contentlength=?, lastModify=? where shareId=?', (location, url, name, ext, isdir, access, validity, size, UtilFunc.Now(), shareId))
        sqlStr = 'update shares set location=?, url=?, name=?, contentType=?, isFolder=?, extractionCode=?, validity=?, contentlength=?, lastModify=? where shareId=?'
        ret = SqliteFunc.execSql(sqlStr, (location, url, name, ext, isdir, access, validity, size, UtilFunc.Now(), shareId,))
    _shareMutex.release()
    return ret