Browse Source

Fixed restoring documents

Krzysztof Krysiński 3 years ago
parent
commit
a4b41b5efa

+ 7 - 5
PixiEditor/Models/DataHolders/CrashReport.cs

@@ -91,8 +91,9 @@ namespace PixiEditor.Models.DataHolders
 
 
         public int GetDocumentCount() => ZipFile.Entries.Where(x => x.FullName.EndsWith(".pixi")).Count();
         public int GetDocumentCount() => ZipFile.Entries.Where(x => x.FullName.EndsWith(".pixi")).Count();
 
 
-        public IEnumerable<Document> RecoverDocuments()
+        public List<Document> RecoverDocuments()
         {
         {
+            List<Document> documents = new();
             foreach (ZipArchiveEntry entry in ZipFile.Entries.Where(x => x.FullName.EndsWith(".pixi")))
             foreach (ZipArchiveEntry entry in ZipFile.Entries.Where(x => x.FullName.EndsWith(".pixi")))
             {
             {
                 using Stream stream = entry.Open();
                 using Stream stream = entry.Open();
@@ -109,8 +110,10 @@ namespace PixiEditor.Models.DataHolders
                     continue;
                     continue;
                 }
                 }
 
 
-                yield return document;
+                documents.Add(document);
             }
             }
+
+            return documents;
         }
         }
 
 
         public void Dispose()
         public void Dispose()
@@ -159,15 +162,14 @@ namespace PixiEditor.Models.DataHolders
                 try
                 try
                 {
                 {
                     string documentPath =
                     string documentPath =
-                        $"{(string.IsNullOrWhiteSpace(document.DocumentFilePath) ? "Unsaved" : Path.GetFileNameWithoutExtension(document.DocumentFilePath))}-{document.OpenedUTC}.pixi";
+                        $"{(string.IsNullOrWhiteSpace(document.DocumentFilePath) ? "Unsaved" : Path.GetFileNameWithoutExtension(document.DocumentFilePath))}-{document.OpenedUTC}.pixi".Replace(':', '_');
 
 
                     byte[] serialized = PixiParser.Serialize(document.ToSerializable());
                     byte[] serialized = PixiParser.Serialize(document.ToSerializable());
 
 
                     using Stream documentStream = archive.CreateEntry($"Documents/{documentPath}").Open();
                     using Stream documentStream = archive.CreateEntry($"Documents/{documentPath}").Open();
                     documentStream.Write(serialized);
                     documentStream.Write(serialized);
                 }
                 }
-                catch
-                { }
+                catch { }
             }
             }
         }
         }
 
 

+ 1 - 0
PixiEditor/ViewModels/CrashReportViewModel.cs

@@ -2,6 +2,7 @@
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Views.Dialogs;
 using PixiEditor.Views.Dialogs;
 using System.Diagnostics;
 using System.Diagnostics;
+using System.Linq;
 using System.Windows;
 using System.Windows;
 
 
 namespace PixiEditor.ViewModels
 namespace PixiEditor.ViewModels