mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Compare commits
6 Commits
b68f6f792f
...
f6500da3ff
| Author | SHA1 | Date | |
|---|---|---|---|
|
f6500da3ff
|
|||
|
3cd5cf4b73
|
|||
|
078348c054
|
|||
|
d26000c7c8
|
|||
|
2942c6dfc8
|
|||
|
5265ad4ef8
|
@@ -327,6 +327,9 @@ public partial class ImportRoms : ComponentBase
|
||||
|
||||
if(!archiveImporter.IsCrcInDb(reader.Entry.Crc) && KnownOnlyChecked) continue;
|
||||
|
||||
// Do not import files that are already in the repository
|
||||
if(archiveImporter.IsInRepo(reader.Entry.Crc)) continue;
|
||||
|
||||
var worker = new FileImporter(_ctx,
|
||||
_newFiles,
|
||||
_newDisks,
|
||||
@@ -342,10 +345,24 @@ public partial class ImportRoms : ComponentBase
|
||||
tmpFile,
|
||||
reader.Entry.Size);
|
||||
|
||||
if(File.Exists(tmpFile)) File.Delete(tmpFile);
|
||||
try
|
||||
{
|
||||
if(File.Exists(tmpFile)) File.Delete(tmpFile);
|
||||
}
|
||||
catch(IOException)
|
||||
#pragma warning disable PH2098
|
||||
{
|
||||
// Ignore IO exceptions when deleting temporary files
|
||||
}
|
||||
#pragma warning restore PH2098
|
||||
}
|
||||
}
|
||||
catch(InvalidOperationException) {}
|
||||
#pragma warning disable RCS1075, PH2098, ERP022
|
||||
catch(Exception)
|
||||
{
|
||||
// Show must go on
|
||||
}
|
||||
#pragma warning restore RCS1075, PH2098, ERP022
|
||||
finally
|
||||
{
|
||||
Interlocked.Increment(ref _listPosition);
|
||||
|
||||
@@ -556,6 +556,14 @@ public sealed class FileImporter
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInRepo(long crc32)
|
||||
{
|
||||
lock(DbLock)
|
||||
{
|
||||
return _ctx.Files.Any(f => f.Crc32 == crc32.ToString("x8") && f.IsInRepo);
|
||||
}
|
||||
}
|
||||
|
||||
public void ImportAndHashRom(Stream stream, string filename, string tempPath, long size)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -65,6 +65,7 @@ internal static class Program
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
|
||||
#if DEBUG
|
||||
.LogToSerilog(LogEventLevel.Debug);
|
||||
#else
|
||||
|
||||
18
RomRepoMgr/Resources/Localization.Designer.cs
generated
18
RomRepoMgr/Resources/Localization.Designer.cs
generated
@@ -788,5 +788,23 @@ namespace RomRepoMgr.Resources {
|
||||
return ResourceManager.GetString("ProcessingArchive", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string ErrorProcessingArchive {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorProcessingArchive", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string UnknownFile {
|
||||
get {
|
||||
return ResourceManager.GetString("UnknownFile", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string FileAlreadyInRepository {
|
||||
get {
|
||||
return ResourceManager.GetString("FileAlreadyInRepository", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,4 +390,13 @@ Tardará mucho tiempo...</value>
|
||||
<data name="ProcessingArchive" xml:space="preserve">
|
||||
<value>Procesando archivo: {0}</value>
|
||||
</data>
|
||||
<data name="ErrorProcessingArchive" xml:space="preserve">
|
||||
<value>Error procesando archivo.</value>
|
||||
</data>
|
||||
<data name="UnknownFile" xml:space="preserve">
|
||||
<value>Fichero desconocido.</value>
|
||||
</data>
|
||||
<data name="FileAlreadyInRepository" xml:space="preserve">
|
||||
<value>Fichero ya en el repositorio.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -398,4 +398,13 @@ This will take a long time...</value>
|
||||
<data name="ProcessingArchive" xml:space="preserve">
|
||||
<value>Processing archive: {0}</value>
|
||||
</data>
|
||||
<data name="ErrorProcessingArchive" xml:space="preserve">
|
||||
<value>Error processing archive.</value>
|
||||
</data>
|
||||
<data name="UnknownFile" xml:space="preserve">
|
||||
<value>Unknown file.</value>
|
||||
</data>
|
||||
<data name="FileAlreadyInRepository" xml:space="preserve">
|
||||
<value>File already in repository.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -404,11 +404,41 @@ public sealed partial class ImportRomFolderViewModel : ViewModelBase
|
||||
// Process files in archive
|
||||
while(reader.MoveToNextEntry())
|
||||
{
|
||||
string filename = Path.GetFileName(reader.Entry.Key);
|
||||
|
||||
if(reader.Entry.IsDirectory) continue;
|
||||
|
||||
if(reader.Entry.Crc == 0 && KnownOnlyChecked) continue;
|
||||
if(reader.Entry.Crc == 0 && KnownOnlyChecked ||
|
||||
!archiveImporter.IsCrcInDb(reader.Entry.Crc) && KnownOnlyChecked)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => Importers.Add(new RomImporter
|
||||
{
|
||||
Filename = filename,
|
||||
Indeterminate = false,
|
||||
Progress = 1,
|
||||
Maximum = 1,
|
||||
Minimum = 0,
|
||||
StatusMessage = Localization.UnknownFile
|
||||
}));
|
||||
|
||||
if(!archiveImporter.IsCrcInDb(reader.Entry.Crc) && KnownOnlyChecked) continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not import files that are already in the repository
|
||||
if(archiveImporter.IsInRepo(reader.Entry.Crc))
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => Importers.Add(new RomImporter
|
||||
{
|
||||
Filename = filename,
|
||||
Indeterminate = false,
|
||||
Progress = 1,
|
||||
Maximum = 1,
|
||||
Minimum = 0,
|
||||
StatusMessage = Localization.FileAlreadyInRepository
|
||||
}));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var model = new RomImporter
|
||||
{
|
||||
@@ -440,10 +470,32 @@ public sealed partial class ImportRomFolderViewModel : ViewModelBase
|
||||
tmpFile,
|
||||
reader.Entry.Size);
|
||||
|
||||
if(File.Exists(tmpFile)) File.Delete(tmpFile);
|
||||
try
|
||||
{
|
||||
if(File.Exists(tmpFile)) File.Delete(tmpFile);
|
||||
}
|
||||
catch(IOException)
|
||||
#pragma warning disable PH2098
|
||||
{
|
||||
// Ignore IO exceptions when deleting temporary files
|
||||
}
|
||||
#pragma warning restore PH2098
|
||||
}
|
||||
}
|
||||
catch(InvalidOperationException) {}
|
||||
catch(Exception)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => Importers.Add(new RomImporter
|
||||
{
|
||||
Filename = Path.GetFileName(archive),
|
||||
Indeterminate = false,
|
||||
Progress = 1,
|
||||
Maximum = 1,
|
||||
Minimum = 0,
|
||||
StatusMessage = Localization.ErrorProcessingArchive
|
||||
}));
|
||||
#pragma warning disable ERP022
|
||||
}
|
||||
#pragma warning restore ERP022
|
||||
finally
|
||||
{
|
||||
Interlocked.Increment(ref _listPosition);
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "9.0.301"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user