bool QgsOracleTableCache::hasCache( const QString& connName, CacheFlags flags ) { sqlite3* db = _openCacheDatabase(); if ( !db ) return false; bool hasCache = _hasCache( db, connName, ( int ) flags ); sqlite3_close( db ); return hasCache; }
static bool _renameConnectionInCache( sqlite3* db, const QString& oldName, const QString& newName ) { if ( !_hasCache( db, oldName ) ) return true; QString sql1 = QString( "ALTER TABLE %1 RENAME TO %2" ).arg( QgsOracleConn::quotedIdentifier( "oracle_" + oldName ) ).arg( QgsOracleConn::quotedIdentifier( "oracle_" + newName ) ); bool res1 = _executeSqliteStatement( db, sql1 ); QString sql2 = QString( "UPDATE meta_oracle SET conn = %1 WHERE conn = %2" ).arg( QgsOracleConn::quotedIdentifier( newName ) ).arg( QgsOracleConn::quotedIdentifier( oldName ) ); bool res2 = _executeSqliteStatement( db, sql2 ); return res1 && res2; }
int isPreloadedFile (const char *path) { int status; char iRODSPath[MAX_NAME_LEN]; status = _getiRODSPath(path, iRODSPath); if(status < 0) { rodsLog (LOG_DEBUG, "isPreloadedFile: failed to get iRODS path - %s", path); return status; } LOCK(PreloadLock); status = _hasCache(iRODSPath); UNLOCK(PreloadLock); return status; }
int isPreloaded (const char *path) { int status; char iRODSPath[MAX_NAME_LEN]; status = _getiRODSPath(path, iRODSPath); if(status < 0) { rodsLogError(LOG_ERROR, status, "isPreloaded: _getiRODSPath error."); rodsLog (LOG_ERROR, "isPreloaded: failed to get iRODS path - %s", path); return status; } LOCK(PreloadLock); status = _hasCache(iRODSPath); UNLOCK(PreloadLock); return status; }
int openPreloadedFile (const char *path) { int status; char iRODSPath[MAX_NAME_LEN]; char preloadCachePath[MAX_NAME_LEN]; preloadFileHandleInfo_t *preloadFileHandleInfo = NULL; int desc; status = _getiRODSPath(path, iRODSPath); if(status < 0) { rodsLogError(LOG_ERROR, status, "openPreloadedFile: _getiRODSPath error."); rodsLog (LOG_ERROR, "openPreloadedFile: failed to get iRODS path - %s", path); return status; } status = _getCachePath(iRODSPath, preloadCachePath); if(status < 0) { rodsLogError(LOG_ERROR, status, "openPreloadedFile: _getCachePath error."); rodsLog (LOG_ERROR, "openPreloadedFile: failed to get cache path - %s", path); return status; } LOCK(PreloadLock); desc = -1; preloadFileHandleInfo = (preloadFileHandleInfo_t *)lookupFromHashTable(PreloadFileHandleTable, iRODSPath); if(preloadFileHandleInfo != NULL) { // has preload file handle opened if(preloadFileHandleInfo->handle > 0) { // reuse handle desc = preloadFileHandleInfo->handle; rodsLog (LOG_DEBUG, "openPreloadedFile: file is already opened - %s", iRODSPath); } else { // reuse handleinfo if(_hasCache(iRODSPath) >= 0) { desc = open (preloadCachePath, O_RDONLY); if(desc > 0) { preloadFileHandleInfo->handle = desc; rodsLog (LOG_DEBUG, "openPreloadedFile: opens a file handle - %s", iRODSPath); } } } } else { // if preloaded cache file is not opened // open new if(_hasCache(iRODSPath) >= 0) { desc = open (preloadCachePath, O_RDONLY); rodsLog (LOG_DEBUG, "openPreloadedFile: open a preloaded cache path - %s", iRODSPath); if(desc > 0) { preloadFileHandleInfo = (preloadFileHandleInfo_t *)malloc(sizeof(preloadFileHandleInfo_t)); preloadFileHandleInfo->path = strdup(iRODSPath); preloadFileHandleInfo->handle = desc; INIT_STRUCT_LOCK((*preloadFileHandleInfo)); insertIntoHashTable(PreloadFileHandleTable, iRODSPath, preloadFileHandleInfo); } } } UNLOCK(PreloadLock); return desc; }