mirror of
https://github.com/manos555555/PS5-Suite.git
synced 2026-10-06 13:00:25 +02:00
🎯 New Feature: - Added duplicate file detection before upload - Shows dialog when file already exists on PS5 - Options: Replace / Skip / Replace All / Skip All 📋 How It Works: 1. Before upload, checks all files against existing PS5 files 2. Groups files by directory to minimize ListDir calls 3. Shows dialog for each duplicate with file sizes 4. User can choose action per file or apply to all 🎨 UI: - New DuplicateFileDialog.xaml with modern dark theme - Shows local and remote file sizes - 4 action buttons with clear labels 💡 Benefits: - No need to manually delete folders before re-upload - Skip already uploaded files automatically - Replace only changed files - Saves time on failed upload retries 📝 Files Changed: - client/MainWindow.xaml.cs: Added FilterDuplicateFilesAsync method - client/DuplicateFileDialog.xaml: New dialog UI - client/DuplicateFileDialog.xaml.cs: Dialog logic with FileAction enum 🔧 Technical: - Uses existing ListDir protocol to check file existence - Efficient: Groups files by directory to minimize network calls - Maintains user choice (Replace All / Skip All) across files
68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
using System.Windows;
|
|
|
|
namespace PS5Upload
|
|
{
|
|
public partial class DuplicateFileDialog : Window
|
|
{
|
|
public enum FileAction
|
|
{
|
|
Replace,
|
|
Skip,
|
|
ReplaceAll,
|
|
SkipAll
|
|
}
|
|
|
|
public FileAction UserAction { get; private set; }
|
|
|
|
public DuplicateFileDialog(string fileName, long localSize, long remoteSize)
|
|
{
|
|
InitializeComponent();
|
|
|
|
FileNameTextBlock.Text = fileName;
|
|
LocalSizeTextBlock.Text = $"Local file: {FormatFileSize(localSize)}";
|
|
RemoteSizeTextBlock.Text = $"Remote file: {FormatFileSize(remoteSize)}";
|
|
}
|
|
|
|
private void Replace_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
UserAction = FileAction.Replace;
|
|
DialogResult = true;
|
|
Close();
|
|
}
|
|
|
|
private void Skip_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
UserAction = FileAction.Skip;
|
|
DialogResult = true;
|
|
Close();
|
|
}
|
|
|
|
private void ReplaceAll_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
UserAction = FileAction.ReplaceAll;
|
|
DialogResult = true;
|
|
Close();
|
|
}
|
|
|
|
private void SkipAll_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
UserAction = FileAction.SkipAll;
|
|
DialogResult = true;
|
|
Close();
|
|
}
|
|
|
|
private string FormatFileSize(long bytes)
|
|
{
|
|
string[] sizes = { "B", "KB", "MB", "GB", "TB" };
|
|
double len = bytes;
|
|
int order = 0;
|
|
while (len >= 1024 && order < sizes.Length - 1)
|
|
{
|
|
order++;
|
|
len = len / 1024;
|
|
}
|
|
return $"{len:0.##} {sizes[order]}";
|
|
}
|
|
}
|
|
}
|