Skip to content

Commit a481ef1

Browse files
committed
Start fixing "file in process" bug. (not ready)
1 parent effb36b commit a481ef1

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

ByteMeBackup/Configuration/AppConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class BackupConfig
1111
{
1212
public string BackupPath { get; set; } = string.Empty;
1313
public string BackupPrefix { get; set; } = string.Empty;
14-
14+
1515
// Soon to be implemented
1616
// public ??? BackupSchedule { get; set; } = ???;
1717
public BackupType BackupType { get; set; } = BackupType.MountedDrive;

ByteMeBackup/Core/BackupTask.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ public async Task Run()
2929

3030
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
3131
var zipFileName = $"{BackupConfig.BackupPrefix}{timestamp}.zip";
32-
FileHelper.CopyDirectory(BackupConfig.BackupPath, Path.GetTempPath() + zipFileName, false);
32+
var tempBackupPath = Path.GetTempPath() + "/backup/" + BackupConfig.BackupPrefix + timestamp;
33+
var tempZipPath = Path.Combine(Path.GetTempPath(), zipFileName);
3334

3435

35-
var tempZipPath = Path.Combine(Path.GetTempPath(), zipFileName);
36-
var tempBackupPath = Path.GetTempPath() + zipFileName;
37-
36+
FileHelper.CopyDirectory(BackupConfig.BackupPath, Path.GetTempPath() + zipFileName,
37+
true);
3838
ZipFile.CreateFromDirectory(tempBackupPath, tempZipPath);
3939

4040
await LogAsync($"""
@@ -70,7 +70,7 @@ await LogAsync($"""
7070
File.Delete(tempBackupPath);
7171
await LogAsync(
7272
"-# Temporary zip file deleted successfully!",
73-
$"[grey]Deleted temporary file: {tempZipPath}[/]"
73+
$"[grey]Deleted temporary file: {tempZipPath}[/]\n[grey]Deleted temporary file: {tempBackupPath}[/]"
7474
);
7575
}
7676
catch (Exception e)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGuid_002EWindows_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003Fa42ba4db448ed38dcb9fb39194c637a317a8281856b88e139e8a905ee6d12b_003FGuid_002EWindows_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

ByteMeBackup/Helper/FileHelper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ public static void CopyDirectory(string sourceDir, string destinationDir, bool r
2323
foreach (var file in dir.GetFiles())
2424
{
2525
var targetFilePath = Path.Combine(destinationDir, file.Name);
26-
file.CopyTo(targetFilePath);
26+
using var sourceFileStream = new FileStream(file.FullName, FileMode.Open, FileAccess.ReadWrite);
27+
using var targetFileStream = new FileStream(targetFilePath, FileMode.CreateNew, FileAccess.ReadWrite);
28+
sourceFileStream.CopyTo(targetFileStream);
29+
sourceFileStream.Close();
30+
targetFileStream.Close();
2731
}
2832

2933
// If recursive and copying subdirectories, recursively call this method

ByteMeBackup/Version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ namespace ByteMeBackup;
22

33
public abstract class Version
44
{
5-
public const string VersionNumber = "1.1.0";
5+
public const string VersionNumber = "1.2.0";
66
}

0 commit comments

Comments
 (0)