Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RupertAvery committed Apr 21, 2024
1 parent d70e938 commit 9269cd0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
5 changes: 1 addition & 4 deletions Diffusion.Toolkit/Controls/ThumbnailView.xaml.Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ public void ReloadThumbnailsView(double offset)

var item = wrapPanel.Children[0] as ListViewItem;

if (item.ActualWidth == 0) return;

var columnWidth = (int)(wrapPanel.ActualWidth / item.ActualWidth);


double top = 0;
double left = 0;
var maxHeight = item.ActualHeight;
Expand Down
45 changes: 29 additions & 16 deletions Diffusion.Toolkit/MainWindow.xaml.Scanning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private Task ScanUnavailable(UnavailableFilesModel options)
var status = scanning
.Replace("{current}", $"{_model.CurrentProgress:#,###,##0}")
.Replace("{total}", $"{_model.TotalProgress:#,###,##0}");
_model.Status = status;
});
}
Expand Down Expand Up @@ -140,7 +140,7 @@ private Task ScanUnavailable(UnavailableFilesModel options)
if (options.DeleteImmediately)
{
_dataStore.RemoveImages(candidateImages);
var removed = GetLocalizedText("UnavailableFiles.Results.Removed");
removed = removed.Replace("{count}", $"{candidateImages.Count:#,###,##0}");
Expand Down Expand Up @@ -322,7 +322,7 @@ private int FixFoldersInternal()
return updated;
}

private async Task MoveFiles(ICollection<ImageEntry> images, string path, bool remove)
private async Task MoveFiles(ICollection<ImageEntry> images, string targetPath, bool remove)
{

foreach (var watcher in _watchers)
Expand All @@ -344,26 +344,39 @@ private async Task MoveFiles(ICollection<ImageEntry> images, string path, bool r
{

string newPath = "";
string newTxtPath = "";
string fileName = "";
string fileNameOnly = "";
string extension = "";
int increment = 0;


var directoryName = Path.GetDirectoryName(image.Path);


string originalFileNameOnly = Path.GetFileNameWithoutExtension(image.Path);

fileName = Path.GetFileName(image.Path);
extension = Path.GetExtension(image.Path);

var txtFileName = $"{originalFileNameOnly}.txt";
var txtPath = Path.Join(directoryName, txtFileName);

newPath = Path.Join(targetPath, fileName);
newTxtPath = Path.Join(targetPath, txtFileName);

// append number if file exists at target
do
while (File.Exists(newPath))
{
var fileName = Path.GetFileName(image.Path);
if (increment > 0)
fileName = increment.ToString() + "_" + fileName;
newPath = Path.Join(path, fileName);
increment++;
} while (File.Exists(newPath));
fileNameOnly = $"{originalFileNameOnly} ({increment})";
fileName = $"{fileNameOnly}{extension}";
txtFileName = $"{fileNameOnly}.txt";

var directoryName = Path.GetDirectoryName(image.Path);
var fileNameOnly = Path.GetFileNameWithoutExtension(fileName);
newPath = Path.Join(targetPath, fileName);
newTxtPath = Path.Join(targetPath, txtFileName);
};

var txtFileName = $"{fileNameOnly}.txt";

var txtPath = Path.Join(directoryName, txtFileName);
var newTxtPath = Path.Join(path, txtFileName);

if (image.Path != newPath)
{
File.Move(image.Path, newPath);
Expand Down

0 comments on commit 9269cd0

Please sign in to comment.