3 Commits
Author SHA1 Message Date
Radio f0e60b418f Merge branch 'master' of https://github.com/Radioo/WPFLinkTool 2022-07-24 09:13:04 +02:00
Radio 7b79485ccc Add a warning for low disk space and display free space in the "Other" tab 2022-07-24 09:12:44 +02:00
Radio 5ce853bc5f Update README.md
Hopefully a clearer explanation
2022-07-24 08:08:00 +02:00
5 changed files with 87 additions and 10 deletions
+2 -2
View File
@@ -7,8 +7,8 @@
<UseWPF>true</UseWPF>
<UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>LL_logo.ico</ApplicationIcon>
<AssemblyVersion>2.1.0</AssemblyVersion>
<FileVersion>2.1.0</FileVersion>
<AssemblyVersion>2.2.0</AssemblyVersion>
<FileVersion>2.2.0</FileVersion>
</PropertyGroup>
<ItemGroup>
+42 -3
View File
@@ -110,10 +110,13 @@ namespace LincleLINK
dialog.Dispose();
}
public void MakeInstance(object o)
public async void MakeInstance(object o)
{
LogList.Add("Validating...");
if (ValidateInstance())
UIEnabled = false;
bool validate_result = await Task.Run(() => ValidateInstance());
UIEnabled = true;
if (validate_result)
{
LogList.Add("Good to go!");
try
@@ -128,7 +131,7 @@ namespace LincleLINK
}
public bool ValidateInstance()
{
{
if (string.IsNullOrWhiteSpace(InstanceName))
{
System.Windows.Forms.MessageBox.Show("Instance name cannot be empty.",
@@ -174,6 +177,42 @@ namespace LincleLINK
}
}
// check if there is enough space for copying
if (IsCopyChecked)
{
DirectoryInfo files = new(DataPath);
long size_to_copy = 0;
foreach (var file in files.GetFiles("*", SearchOption.AllDirectories))
{
size_to_copy += file.Length;
}
var drives = DriveInfo.GetDrives();
long free_space = 0;
foreach (var drive in drives)
{
if (MainWindowLogic.currentDir.StartsWith(drive.Name))
{
free_space = drive.AvailableFreeSpace;
}
}
if (size_to_copy + 100000000 > free_space) // add a 100MB wiggle room
{
if (MessageBox.Show($"Current drive is low on disk space, do you want to continue? " +
$"Free space: {Instance.ReadableSize(free_space)}, Size of files about to copy: {Instance.ReadableSize(size_to_copy)}", "Low disk space!",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
return true;
}
else
{
return false;
}
}
}
return true;
}
+20
View File
@@ -180,6 +180,17 @@ namespace LincleLINK
}
}
private string _freeSpace;
public string FreeSpace
{
get { return _freeSpace; }
set
{
_freeSpace = value;
OnPropertyChanged(nameof(FreeSpace));
}
}
public SynchronizationContext UIContext { get; set; }
public Dictionary<PassedFileInfo, HashSet<long>>? FilePieceMap { get; set; }
public List<long>? BadPieces { get; set; }
@@ -754,6 +765,15 @@ namespace LincleLINK
instTotal += inst.TotalFileSize;
}
Savings = Instance.ReadableSize(instTotal - dbSize);
var drives = DriveInfo.GetDrives();
foreach (var drive in drives)
{
if (currentDir.StartsWith(drive.Name))
{
FreeSpace = Instance.ReadableSize(drive.AvailableFreeSpace);
}
}
}
public async void CopyFiles(object o)
+2 -1
View File
@@ -160,11 +160,12 @@
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding DBSize, StringFormat=db folder size: {0}}"></TextBlock>
<TextBlock Grid.Row="1" Text="{Binding Savings, StringFormat=You are saving: {0}}"></TextBlock>
<TextBlock Grid.Row="2" Text="{Binding FreeSpace, StringFormat=Free drive space {0}}"></TextBlock>
<Button Grid.Row="3" Content="Import DBInfo.xml" IsEnabled="{Binding IsFree}" Command="{Binding ImportLegacyCommand}"></Button>
</Grid>
+21 -4
View File
@@ -1,10 +1,27 @@
# LincleLINK
This program is designed to store all your arcade data in its own `db` folder. When you add an instance, it produces an MD5 hash of the file and stores it in the `db` folder. Only new and unique files are added, but the record of the file and its location in the original folder is also stored in the instance `.json` file.
# How does it work?
You can then create hard links to your desired destination(s).
## File storage
The tool's main purpose is to store all your data in its own `db` folder. The files are renamed to their MD5 hash which ensures only unique files are added to the `db` folder.
***It is highly recommended to only add the `data` folder of a game as an instance.***
***Also remember that hard links only work on the same partition, additionally editing/modifying hard-linked files will change the originals in the `db` so take extra care. Delete a hard-linked file first if you want to replace/modify it!***
## Instances
Instances are simply a record of: file names, their hashes and their location whithin the original data structure. When adding an instance, you have an option of choosing to copy or move files to the `db`. Moving is advised to reduce space and disk stress. ***It is highly recommended to only add the `data` folder of a game as an instance.***
Here's an example of one file record:
```
{
"FileName": "25063_pre.2dx",
"RelativePath": "sound\\25063",
"FileSize": 463806,
"HashedFileName": "7AFE6AC1B80128D44BA5357D4349B21A.2dx"
},
```
## Linking
When you've added at least one instance, you can link it to your desired destination. The tool will make hard links and keep the original file names and directory structure of the original files. ***Hard links only work on the same partition. If you wish to edit/replace a hard-linked file, delete it first! Directly modifying hard-linked files will alter the originals in the `db`!***
# How does it save space?
When adding subsequent instances, only unique files will be added to the `db`. For example say you have IIDX28 added as an instance, then you add your IIDX27 data as well. Only files unique to IIDX27 will be copied/moved, in turn `db` size will increase by about 4GB instead of 60GB.
![screenshot](https://stn.s-ul.eu/O84VELWa.png)