[chronojump] Automated backups size is calculated
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Automated backups size is calculated
- Date: Tue, 27 Jul 2021 15:25:42 +0000 (UTC)
commit 42a7977a118d8bcb30450f56e3abf19f8c73e038
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jul 27 17:25:20 2021 +0200
Automated backups size is calculated
src/gui/app1/chronojump.cs | 9 +++++++++
src/util.cs | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
---
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 18ba88dee..57702e6fd 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -986,6 +986,15 @@ public partial class ChronoJumpWindow
//InterpolateSignal.TestCosineAndCubicInterpolate(true);
//ConvertBooleansInt.Test();
+
+ /*
+ //Get size of automated backups dir
+ int files;
+ int sizeInKB;
+ Util.GetBackupsSize (out files, out sizeInKB);
+ LogB.Information(string.Format("Backups files: {0}, total size: {1} KB.",
+ files, sizeInKB));
+ */
}
diff --git a/src/util.cs b/src/util.cs
index 85350777c..d76955c78 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1380,6 +1380,22 @@ public class Util
}
}
+ public static void GetBackupsSize (out int files, out int sizeInKB)
+ {
+ DirectoryInfo info = new DirectoryInfo(backupDir);
+ //long totalSize = info.EnumerateFiles().Sum(file => file.Length); //LinQ 4.0
+ //long totalSize = info.GetFiles().Sum(file => file.Length); //LinQ 3.5
+
+ files = 0;
+ long totalSize = 0;
+ foreach(var file in info.EnumerateFiles())
+ {
+ totalSize += file.Length;
+ files ++;
+ }
+ sizeInKB = (int) UtilAll.DivideSafe(totalSize, 1024);
+ }
+
public static bool FileDelete(string fileName)
{
LogB.Information("Checking if this filename exists: " + fileName);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]