コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: GVFSDatabase.cs プロジェクト: toasterpic/VFSForGit
 public GVFSConnection(GVFSDatabase database, IDbConnection connection)
 {
     this.database   = database;
     this.connection = connection;
 }