[chronojump] UtilCopy prepared to discard unwanted sessions (for exportSession)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] UtilCopy prepared to discard unwanted sessions (for exportSession)
- Date: Fri, 26 Jun 2020 14:10:00 +0000 (UTC)
commit ede57ef13951731749a29c2de5a629ce07a74285
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jun 26 16:06:10 2020 +0200
UtilCopy prepared to discard unwanted sessions (for exportSession)
src/gui/app1/session/backup.cs | 5 ++---
src/util.cs | 19 ++++++++++++++++---
2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/src/gui/app1/session/backup.cs b/src/gui/app1/session/backup.cs
index df80ab6f..e2896e6a 100644
--- a/src/gui/app1/session/backup.cs
+++ b/src/gui/app1/session/backup.cs
@@ -133,7 +133,7 @@ public partial class ChronoJumpWindow
} else {
//if multimedia_and_encoder, then copy the folder. If not checked, then copy
only the db file
//if(check_backup_multimedia_and_encoder.Active) {
- app1s_uc = new UtilCopy();
+ app1s_uc = new UtilCopy(-1); //all sessions
app1s_threadBackup = new Thread(new ThreadStart(app1s_copyRecursive));
GLib.Idle.Add (new GLib.IdleHandler (app1s_BackupPulseGTK));
@@ -216,7 +216,7 @@ public partial class ChronoJumpWindow
//if multimedia_and_encoder, then copy the folder. If not checked, then copy only the
db file
//if(check_backup_multimedia_and_encoder.Active) {
Directory.Delete(app1s_fileCopy, true);
- app1s_uc = new UtilCopy();
+ app1s_uc = new UtilCopy(-1); //all sessions
app1s_threadBackup = new Thread(new ThreadStart(app1s_copyRecursive));
GLib.Idle.Add (new GLib.IdleHandler (app1s_BackupPulseGTK));
@@ -243,7 +243,6 @@ public partial class ChronoJumpWindow
*/
static long app1s_copyRecursiveElapsedMs;
static int app1s_backupMainDirsDone;
- //static UtilCopy uc;
private void app1s_copyRecursive()
{
app1s_copyRecursiveElapsedMs = 0;
diff --git a/src/util.cs b/src/util.cs
index f80d4ed8..7215d17b 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -2303,17 +2303,22 @@ public class UtilCopy
public int BackupSecondDirsLength;
public string LastMainDir;
public string LastSecondDir;
+ private int sessionID;
//to go faster on CopyFilesRecursively
static string backupDir = Util.GetDatabaseDir() + Path.DirectorySeparatorChar + "backup";
- public UtilCopy()
+ //-1 is the default on a backup, means all sessions (regular backup)
+ //4 will only copy files related to session 4 (for export session)
+ public UtilCopy(int sessionID)
{
BackupMainDirsCount = 0;
BackupSecondDirsCount = 0;
BackupSecondDirsLength = 0;
LastMainDir = "";
LastSecondDir = "";
+
+ this.sessionID = sessionID;
}
//http://stackoverflow.com/a/58779
@@ -2329,14 +2334,22 @@ public class UtilCopy
LastMainDir = Util.GetLastPartOfPath (dir.ToString());
BackupSecondDirsCount = 0;
//LogB.Information("at level 0: " + dir);
- } else if(level == 1) {
+ } else if(level == 1)
+ {
+ //discard the unwanted sessions
+ if(sessionID > 0 &&
Util.IsNumber(Util.GetLastPartOfPath(dir.ToString()), false) &&
+
Convert.ToInt32(Util.GetLastPartOfPath(dir.ToString())) != sessionID)
+ {
+ //LogB.Information("Discarded: " + dir.ToString());
+ continue;
+ }
+
BackupSecondDirsLength = diArray.Length;
BackupSecondDirsCount ++;
LastSecondDir = Util.GetLastPartOfPath (dir.ToString());
//LogB.Information("at level 1: " + dir);
}
CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name), level +1);
-
}
foreach (FileInfo file in source.GetFiles())
file.CopyTo(Path.Combine(target.FullName, file.Name));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]