public FileScanner(string startDir, Database database, Logger logger, string name, BackendBase[] backends, string fileIgnorePattern, HashSet<string> ignoredFiles, HashSet<string> ignoredFolders) {
     this.Database = database;
     this.treeTraverser = new TreeTraverser(startDir, fileIgnorePattern, ignoredFiles, ignoredFolders);
     this.fileDatabase = new FileDatabase(database);
     this.backends = backends;
     foreach (BackendBase backend in this.backends) {
         backend.CopyProgress += new BackendBase.CopyProgressEventHandler(Backend_CopyProgress);
     }
     this.Logger = logger;
     this.Name = name;
 }
Beispiel #2
0
 public Settings(Database db) {
     this.db = db;
 }
        //http://www.dreamincode.net/forums/topic/157830-using-sqlite-with-c%23/

        public FileDatabase(Database db) {
            //this.cachedInserts = new List<CachedInsert>();
            this.db = db;
        }
Beispiel #4
0
        public static Database CreateDatabase(string path) {
            Database database = new Database(path);

            database.Execute(@"CREATE TABLE folders( id INTEGER PRIMARY KEY, parent_id INTEGER, name TEXT COLLATE NOCASE, path TEXT COLLATE NOCASE,
                FOREIGN KEY(parent_id) REFERENCES folders(id) );");
            database.Execute("CREATE INDEX folders_name_idx ON folders(name);");
            database.Execute("CREATE INDEX folders_path_idx ON folders(path);");
            database.Execute(@"CREATE TABLE files( id INTEGER PRIMARY KEY, folder_id INTEGER, name TEXT COLLATE NOCASE, date_modified INTEGER, md5 TEXT COLLATE NOCASE,
                FOREIGN KEY(folder_id) REFERENCES folders(id) );");
            database.Execute(@"CREATE INDEX files_folder_id_idx ON files(folder_id);");
            database.Execute(@"CREATE INDEX files_name_idx ON files(name);");
            database.Execute(@"CREATE UNIQUE INDEX files_folder_id_name ON files(folder_id, name)");
            // We have a foreign key constraint which enforces parent folders. However, root folders have a parentId of 0 (to make the code easier), which violates this.
            // Therefore, add a root entry with an ID of 0 and a parent of null
            database.Execute("INSERT INTO folders (id, parent_id, name, path) VALUES (0, null, 'root', '');");

            database.Execute("CREATE TABLE settings( id INTEGER PRIMARY KEY, name TEXT, value TEXT );");
            database.Execute("CREATE INDEX settings_name_idx ON settings(name)");

            return database;
        }
Beispiel #5
0
 public static string GetExportableFile(string filePath, bool stripFilesFolders=false) {
     // If we're not stripping files and folders, just return the file path
     if (!stripFilesFolders)
         return filePath;
     // Otherwise copy, open, truncate files and folders, close
     string destPath = Path.GetTempFileName();
     File.Copy(filePath, destPath, true);
     Database db = new Database(destPath);
     db.Execute("DELETE FROM 'files'");
     db.Execute("DELETE FROM 'folders'");
     db.Close();
     return destPath;
 }