public void clear() { try{ close(); CRhoFile.deleteFile(m_oLogConf.getLogFilePath()); CRhoFile.deleteFile(m_oLogConf.getLogFilePath() + "_pos"); }catch (Exception) { } }
private void processBlobDelete(int nSrcID, String attrib, String value) { if (value == null || value.length() == 0) { return; } try{ String strFilePath = RHODESAPP().resolveDBFilesPath(value); CRhoFile.deleteFile(strFilePath); }catch (Exception exc) { LOG.ERROR("DBCallback.OnDeleteFromTable: Error delete file: " + value, exc); } }
public static void SyncBlob_DeleteSchemaCallback(Sqlite3.sqlite3_context dbContext, int nArgs, Sqlite3.Mem[] Args) { String value = Sqlite3.sqlite3_value_text(Args[0]); if (value == null) { return; } String strFilePath = RHODESAPP().resolveDBFilesPath(value); if (strFilePath != "") { CRhoFile.deleteFile(strFilePath); } }
public static void SyncBlob_UpdateCallback(Sqlite3.sqlite3_context dbContext, int nArgs, Sqlite3.Mem[] Args) { if (nArgs < 3) { return; } DBAttrManager attrMgr = getDBByHandle(Sqlite3.sqlite3_context_db_handle(dbContext)).getAttrMgr(); String szAttrName = Sqlite3.sqlite3_value_text(Args[2]); int nSrcID = Sqlite3.sqlite3_value_int(Args[1]); if (attrMgr.isBlobAttr(nSrcID, szAttrName)) { String strFilePath = RHODESAPP().resolveDBFilesPath(Sqlite3.sqlite3_value_text(Args[0])); CRhoFile.deleteFile(strFilePath); } }
String makeBulkDataFileName(String strDataUrl, String strDbPath, String strExt) { String strNewName = CFilePath.getBaseName(strDataUrl); String strOldName = RhoConf.getInstance().getString("bulksync_filename"); if (strOldName.length() > 0 && strNewName.compareTo(strOldName) != 0) { String strFToDelete = CFilePath.changeBaseName(strDbPath, strOldName + strExt); LOG.INFO("Bulk sync: remove old bulk file '" + strFToDelete + "'"); //RhoFile.deleteFile( strFToDelete.c_str() ); CRhoFile.deleteFile(strFToDelete); } RhoConf.getInstance().setString("bulksync_filename", strNewName, true); return(CFilePath.changeBaseName(strDbPath, strNewName + strExt)); }
public static void SyncBlob_UpdateSchemaCallback(Sqlite3.sqlite3_context dbContext, int nArgs, Sqlite3.Mem[] Args) { String szOldValue = Sqlite3.sqlite3_value_text(Args[0]); String szNewValue = Sqlite3.sqlite3_value_text(Args[1]); if (szOldValue == szNewValue || szOldValue == null) { return; } if (szOldValue != null && szNewValue != null && szOldValue == szNewValue) { return; } if (szOldValue != null) { String strFilePath = RHODESAPP().resolveDBFilesPath(szOldValue); CRhoFile.deleteFile(strFilePath); } }
public void rb_destroy_tables(Vector <String> vecIncludes, Vector <String> vecExcludes) { if (!m_bIsOpen) { return; } IDBStorage db = null; try{ String dbNewName = CFilePath.changeBaseName(m_strDBPath, "resetdbtemp.sqlite"); CRhoFile.deleteFile(dbNewName); CRhoFile.deleteFile(dbNewName + "-journal"); CRhoFile.deleteFile(dbNewName + ".version"); db = RhoClassFactory.createDBStorage(); db.open(dbNewName, getSqlScript(), getEncryptionInfo()); String[] vecTables = m_dbStorage.getAllTableNames(); //IDBResult res; db.startTransaction(); for (int i = 0; i < vecTables.Length; i++) { String tableName = vecTables[i]; if (destroyTableName(tableName, vecIncludes, vecExcludes)) { continue; } copyTable(tableName, this.m_dbStorage, db); } db.commit(); db.close(); String dbOldName = m_strDBPath; m_dbStorage.close(); m_dbStorage = null; m_bIsOpen = false; CRhoFile.deleteFilesInFolder(RHODESAPP().getBlobsDirPath()); string[] ar1 = CRhoFile.enumDirectory("db"); CRhoFile.deleteFile(dbOldName); CRhoFile.deleteFile(dbOldName + "-journal"); CRhoFile.renameFile(dbNewName, dbOldName); CRhoFile.renameFile(dbNewName + "-journal", dbOldName + "-journal"); string[] ar2 = CRhoFile.enumDirectory("db"); m_dbStorage = RhoClassFactory.createDBStorage(); m_dbStorage.open(m_strDBPath, getSqlScript(), getEncryptionInfo()); m_bIsOpen = true; string[] ar3 = CRhoFile.enumDirectory("db"); m_dbStorage.setDbCallback(new DBCallback(this)); }catch (Exception e) { LOG.ERROR("destroy_table failed.", e); if (!m_bIsOpen) { LOG.ERROR("destroy_table error.Try to open old DB."); try{ m_dbStorage.open(m_strDBPath, getSqlScript(), getEncryptionInfo()); m_bIsOpen = true; }catch (Exception exc) { LOG.ERROR("destroy_table open old table failed.", exc); } } try { if (db != null) { db.close(); } } catch (DBException e1) { LOG.ERROR("closing of DB caused exception: " + e1.Message); } throw e; } }
public void deleteAllFiles(String strPath) { CRhoFile.deleteFile(strPath); CRhoFile.deleteFile(strPath + "-journal"); }
void loadBulkPartition(String strPartition) { DBAdapter dbPartition = getDB(strPartition); String serverUrl = RhoConf.getInstance().getPath("syncserver"); String strUrl = serverUrl + "bulk_data"; String strQuery = "?client_id=" + m_clientID + "&partition=" + strPartition; String strDataUrl = "", strCmd = "", strCryptKey = ""; getNotify().fireBulkSyncNotification(false, "start", strPartition, RhoAppAdapter.ERR_NONE); while (strCmd.length() == 0 && isContinueSync()) { NetResponse resp = getNet().pullData(strUrl + strQuery, this); if (!resp.isOK() || resp.getCharData() == null) { LOG.ERROR("Bulk sync failed: server return an error."); stopSync(); getNotify().fireBulkSyncNotification(true, "", strPartition, RhoAppAdapter.getErrorFromResponse(resp)); return; } LOG.INFO("Bulk sync: got response from server: " + resp.getCharData()); String szData = resp.getCharData(); JSONEntry oJsonEntry = new JSONEntry(szData); strCmd = oJsonEntry.getString("result"); if (oJsonEntry.hasName("url")) { strDataUrl = oJsonEntry.getString("url"); } if (strCmd.compareTo("wait") == 0) { int nTimeout = RhoConf.getInstance().getInt("bulksync_timeout_sec"); if (nTimeout == 0) { nTimeout = 5; } SyncThread.getInstance().wait(nTimeout); strCmd = ""; } } if (strCmd.compareTo("nop") == 0) { LOG.INFO("Bulk sync return no data."); getNotify().fireBulkSyncNotification(true, "", strPartition, RhoAppAdapter.ERR_NONE); return; } if (!isContinueSync()) { return; } getNotify().fireBulkSyncNotification(false, "download", strPartition, RhoAppAdapter.ERR_NONE); String fDataName = makeBulkDataFileName(strDataUrl, dbPartition.getDBPath(), ""); String strZip = ".rzip"; String strSqlDataUrl = CFilePath.join(getHostFromUrl(serverUrl), strDataUrl) + strZip; LOG.INFO("Bulk sync: download data from server: " + strSqlDataUrl); { NetResponse resp1 = getNet().pullFile(strSqlDataUrl, fDataName + strZip, this, null); if (!resp1.isOK()) { LOG.ERROR("Bulk sync failed: cannot download database file."); stopSync(); getNotify().fireBulkSyncNotification(true, "", strPartition, RhoAppAdapter.getErrorFromResponse(resp1)); return; } } if (!isContinueSync()) { return; } LOG.INFO("Bulk sync: unzip db"); if (!RHODESAPP().unzip_file(fDataName + strZip)) { CRhoFile.deleteFile(fDataName + strZip); LOG.ERROR("Bulk sync failed: cannot unzip database file."); stopSync(); getNotify().fireBulkSyncNotification(true, "", strPartition, RhoAppAdapter.ERR_UNEXPECTEDSERVERRESPONSE); return; } CRhoFile.deleteFile(fDataName + strZip); LOG.INFO("Bulk sync: start change db"); getNotify().fireBulkSyncNotification(false, "change_db", strPartition, RhoAppAdapter.ERR_NONE); dbPartition.setBulkSyncDB(fDataName, strCryptKey); processServerSources("{\"partition\":\"" + strPartition + "\"}"); LOG.INFO("Bulk sync: end change db"); getNotify().fireBulkSyncNotification(false, "", strPartition, RhoAppAdapter.ERR_NONE); }
public override void DeleteFile(string path, bool deleteReadOnly) { CRhoFile.deleteFile(path); }