public List <IPlaceholderData> RemoveAllEntriesForFolder(string path) { const string fromWhereClause = "FROM Placeholder WHERE path = @path OR path LIKE @pathWithDirectorySeparator;"; // Normalize the path to match what will be in the database path = GVFSDatabase.NormalizePath(path); try { using (IDbConnection connection = this.connectionPool.GetConnection()) using (IDbCommand command = connection.CreateCommand()) { List <IPlaceholderData> removedPlaceholders = new List <IPlaceholderData>(); command.CommandText = $"SELECT path, pathType, sha {fromWhereClause}"; command.AddParameter("@path", DbType.String, $"{path}"); command.AddParameter("@pathWithDirectorySeparator", DbType.String, $"{path + Path.DirectorySeparatorChar}%"); ReadPlaceholders(command, data => removedPlaceholders.Add(data)); command.CommandText = $"DELETE {fromWhereClause}"; lock (this.writerLock) { command.ExecuteNonQuery(); } return(removedPlaceholders); } } catch (Exception ex) { throw new GVFSDatabaseException($"{nameof(PlaceholderTable)}.{nameof(this.RemoveAllEntriesForFolder)}({path}) Exception", ex); } }
public void Add(string directoryPath) { try { using (IDbConnection connection = this.connectionPool.GetConnection()) using (IDbCommand command = connection.CreateCommand()) { command.CommandText = "INSERT OR REPLACE INTO Sparse (path) VALUES (@path);"; command.AddParameter("@path", DbType.String, GVFSDatabase.NormalizePath(directoryPath)); lock (this.writerLock) { command.ExecuteNonQuery(); } } } catch (Exception ex) { throw new GVFSDatabaseException($"{nameof(SparseTable)}.{nameof(this.Add)}({directoryPath}) Exception: {ex.ToString()}", ex); } }
public void Remove(string directoryPath) { try { using (IDbConnection connection = this.connectionPool.GetConnection()) using (IDbCommand command = connection.CreateCommand()) { command.CommandText = "DELETE FROM Sparse WHERE path = @path;"; command.AddParameter("@path", DbType.String, GVFSDatabase.NormalizePath(directoryPath)); lock (this.writerLock) { command.ExecuteNonQuery(); } } } catch (Exception ex) { throw new GVFSDatabaseException($"{nameof(SparseTable)}.{nameof(this.Remove)}({directoryPath}) Exception: {ex.ToString()}", ex); } }
public GVFSConnection(GVFSDatabase database, IDbConnection connection) { this.database = database; this.connection = connection; }