-fix Copy to Tapecatalog

- only use relative paths
This commit is contained in:
Black_Betty committed 2026-10-05 21:24:28 +02:00
1 parent a3b41679c9
commit 7550cab2c5
3 files changed
+50 -10

No files matched your search

+8 -4
View File
@@ -19,7 +19,7 @@
<Button Content="Export XML" HorizontalAlignment="Right" Height="22" Margin="0,234,10,0" VerticalAlignment="Top" Width="76" Click="EXPORT_LIST" Grid.Column="1"/>
<Button Content="Import XML" HorizontalAlignment="Right" Height="22" Margin="0,256,10,0" VerticalAlignment="Top" Width="76" Click="IMPORT_LIST" Grid.Column="1"/>
<Button Content="-> TapeCat" HorizontalAlignment="Right" Height="22" Margin="0,278,10,0" VerticalAlignment="Top" Width="76" Click="COPY_TO_TAPECATALOG" Grid.Column="1"/>
<ListView x:Name="FilesListView" Margin="10,146,101,10" Grid.ColumnSpan="2">
<ListView x:Name="FilesListView" Margin="10,10,101,10" Grid.ColumnSpan="2">
<ListView.View>
<GridView>
<GridViewColumn Header="Filename" DisplayMemberBinding="{Binding Filename}" Width="300"/>
@@ -38,9 +38,13 @@
</TabItem>
<TabItem Header="Tapecatalog">
<Grid Background="#FFE5E5E5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19*"/>
<ColumnDefinition Width="775*"/>
</Grid.ColumnDefinitions>
<ComboBox x:Name="MediumComboBox" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="200" Grid.ColumnSpan="2"/>
<Button Content="Refresh Mediums" HorizontalAlignment="Left" Height="22" Margin="218,10,0,0" VerticalAlignment="Top" Width="120" Click="REFRESH_MEDIUMS"/>
<Button Content="Copy from SRC-ARC" HorizontalAlignment="Left" Height="22" Margin="343,10,0,0" VerticalAlignment="Top" Width="120" Click="COPY_FROM_SRCARC"/>
<Button Content="Refresh Mediums" HorizontalAlignment="Left" Height="22" Margin="199,10,0,0" VerticalAlignment="Top" Width="120" Click="REFRESH_MEDIUMS" Grid.Column="1"/>
<Button Content="Copy from SRC-ARC" HorizontalAlignment="Left" Height="22" Margin="324,10,0,0" VerticalAlignment="Top" Width="120" Click="COPY_FROM_SRCARC" Grid.Column="1"/>
<ListView x:Name="TapeCatalogListView" Margin="10,44,10,40" Grid.ColumnSpan="2">
<ListView.View>
<GridView>
@@ -50,7 +54,7 @@
</GridView>
</ListView.View>
</ListView>
<Button Content="Export Medium" HorizontalAlignment="Left" Height="22" Margin="468,0,0,374" VerticalAlignment="Top" Width="120" Click="EXPORT_MEDIUM"/>
<Button Content="Export Medium" HorizontalAlignment="Left" Height="22" Margin="449,10,0,0" VerticalAlignment="Top" Width="120" Click="EXPORT_MEDIUM" Grid.Column="1"/>
</Grid>
</TabItem>
<TabItem Header="Copy">
+16 -2
View File
@@ -141,8 +141,22 @@ namespace TapeCatalog
#region (COPY_TO_TAPECATALOG)
private void COPY_TO_TAPECATALOG(object sender, RoutedEventArgs e)
{
// delegate to XML helper to copy entries to TapeCatalog list view
XML.Methods.CopyToTapeCatalog(this, _files, TapeCatalogListView);
// Only copy entries where the verification status indicates OK (checked)
try
{
var okEntries = _files.Where(f => string.Equals(f.Status, "✔", StringComparison.Ordinal)).ToList();
if (okEntries.Count == 0)
{
MessageBox.Show(this, "No verified entries to copy to TapeCatalog.", "Nothing to copy", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
XML.Methods.CopyToTapeCatalog(this, okEntries, TapeCatalogListView);
}
catch (Exception ex)
{
MessageBox.Show(this, $"Error copying to TapeCatalog: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
#endregion (COPY_TO_TAPECATALOG)
#region (COPY_FROM_SRCARC)
+26 -4
View File
@@ -87,13 +87,24 @@ namespace TapeCatalog.Methods
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("path");
if (!Directory.Exists(path)) throw new DirectoryNotFoundException(path);
// normalize source root for reliable relative path calculation
var rootFull = System.IO.Path.GetFullPath(path).TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
foreach (var file in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories))
{
try
{
var fi = new FileInfo(file);
// compute directory relative to source root (remove the source root prefix)
var dirFull = System.IO.Path.GetFullPath(fi.DirectoryName).TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
string relativeDir = string.Empty;
if (dirFull.StartsWith(rootFull, StringComparison.OrdinalIgnoreCase))
relativeDir = dirFull.Length == rootFull.Length ? string.Empty : dirFull.Substring(rootFull.Length).TrimStart(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
else
relativeDir = fi.DirectoryName;
var existing = files.FirstOrDefault(f => string.Equals(f.Filename, fi.Name, StringComparison.OrdinalIgnoreCase)
&& string.Equals(f.FileDir, fi.DirectoryName, StringComparison.OrdinalIgnoreCase));
&& string.Equals(f.FileDir, relativeDir, StringComparison.OrdinalIgnoreCase));
if (existing != null)
{
var newSizeMb = FormatBytesToMb(fi.Length);
@@ -110,7 +121,7 @@ namespace TapeCatalog.Methods
files.Add(new TapeCatalog.FileEntry
{
Filename = fi.Name,
FileDir = fi.DirectoryName,
FileDir = relativeDir,
SizeSrc = FormatBytesToMb(fi.Length),
ModSrc = fi.LastWriteTime.ToString(),
});
@@ -128,13 +139,24 @@ namespace TapeCatalog.Methods
{
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("path");
if (!Directory.Exists(path)) throw new DirectoryNotFoundException(path);
// normalize archive root for reliable relative path calculation
var rootFull = System.IO.Path.GetFullPath(path).TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
foreach (var file in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories))
{
try
{
var fi = new FileInfo(file);
var existing = files.FirstOrDefault(f => string.Equals(f.Filename, fi.Name, StringComparison.Ordinal));
var dirFull = System.IO.Path.GetFullPath(fi.DirectoryName).TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
string relativeDir = string.Empty;
if (dirFull.StartsWith(rootFull, StringComparison.OrdinalIgnoreCase))
relativeDir = dirFull.Length == rootFull.Length ? string.Empty : dirFull.Substring(rootFull.Length).TrimStart(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
else
relativeDir = fi.DirectoryName;
var existing = files.FirstOrDefault(f => string.Equals(f.Filename, fi.Name, StringComparison.Ordinal)
&& string.Equals(f.FileDir, relativeDir, StringComparison.OrdinalIgnoreCase));
if (existing != null)
{
existing.SizeArc = FormatBytesToMb(fi.Length);
@@ -148,7 +170,7 @@ namespace TapeCatalog.Methods
files.Add(new TapeCatalog.FileEntry
{
Filename = fi.Name,
FileDir = fi.DirectoryName,
FileDir = relativeDir,
SizeArc = FormatBytesToMb(fi.Length),
ModArc = fi.LastWriteTime.ToString()
});