예제 #1
0
        public bool DeleteExpiredBackups()
        {
            if (_useDatabase)
            {
                foreach (int backupToDelete in _expiredDBBackups)
                {
                    LoadedBackupDB.DeleteBackup(backupToDelete);
                }
                foreach (int orphanFileEntry in LoadedBackupDB.GetOrphanFiles())
                {
                    string dbBackupFilePath = LoadedBackupDB.GetBackupFilePathByEntryID(orphanFileEntry);

                    if (File.Exists(Path.Combine(FullBackupLocationDBDataPath, dbBackupFilePath)))
                    {
                        File.Delete(Path.Combine(FullBackupLocationDBDataPath, dbBackupFilePath));
                    }

                    LoadedBackupDB.DeleteFile(orphanFileEntry);
                }
                LoadedBackupDB.WriteDatabaseToFile();
                _expiredDBBackups = null;
                return(true); //would come in handy if we ever added a progress dialog.
            }
            else
            {
                foreach (string folderToDelete in _expiredFolders)
                {
                    Directory.Delete(folderToDelete, true);
                }
                _expiredFolders = null;
                return(true); //would come in handy if we ever added a progress dialog.
            }
        }
예제 #2
0
        private bool BackUpWithDatabase()
        {
            if (!Directory.Exists(FullBackupLocationDBDataPath))
            {
                Directory.CreateDirectory(FullBackupLocationDBDataPath);
            }

            int backupID = LoadedBackupDB.StartBackup();

            DialogResult backupResult = _progressDialog.StartProgressDialog(_generalResourceManager.GetString("BackupProgressTitle"), _generalResourceManager.GetString("BackupProgressText"), _source.SourceSize.Value, bg_BackUpWithDatabase_DoWork, backupID);

            if (backupResult != DialogResult.Cancel)
            {
                LoadedBackupDB.CompleteBackup(backupID);
                LoadedBackupDB.WriteDatabaseToFile();
                return(true);
            }
            else
            {
                return(false);
            }
        }