Browse Source

Renaming fixes

Krzysztof Krysiński 2 months ago
parent
commit
d077819105

+ 4 - 4
src/PixiEditor.UpdateInstaller.Exe/PixiEditor.UpdateInstaller.Exe.csproj

@@ -20,22 +20,22 @@
     <ProjectReference Include="..\PixiEditor.UpdateInstaller\PixiEditor.UpdateInstaller\PixiEditor.UpdateInstaller.csproj"/>
     <ProjectReference Include="..\PixiEditor.UpdateInstaller\PixiEditor.UpdateInstaller\PixiEditor.UpdateInstaller.csproj"/>
   </ItemGroup>
   </ItemGroup>
   
   
-  <Target Name="Rename" AfterTargets="AfterBuild" Condition="'$(RuntimeIdentifier)'=='win-x64' or '$(RuntimeIdentifier)'=='win-arm64'">
+  <Target Name="RenameBuildWin" AfterTargets="AfterBuild" Condition="'$(RuntimeIdentifier)' =='win-x64' or '$(RuntimeIdentifier)'=='win-arm64'">
     <Move SourceFiles="$(OutDir)PixiEditor.UpdateInstaller.Exe.exe" DestinationFiles="$(OutDir)PixiEditor.UpdateInstaller.exe"/>
     <Move SourceFiles="$(OutDir)PixiEditor.UpdateInstaller.Exe.exe" DestinationFiles="$(OutDir)PixiEditor.UpdateInstaller.exe"/>
     <Message Text="Renamed build executable file." Importance="high"/>
     <Message Text="Renamed build executable file." Importance="high"/>
   </Target>
   </Target>
 
 
-  <Target Name="Rename" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)'=='win-x64' or '$(RuntimeIdentifier)'=='win-arm64'">
+  <Target Name="RenamePublishWin" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)'=='win-x64' or '$(RuntimeIdentifier)'=='win-arm64'">
     <Move SourceFiles="$(PublishDir)PixiEditor.UpdateInstaller.Exe.exe" DestinationFiles="$(PublishDir)PixiEditor.UpdateInstaller.exe"/>
     <Move SourceFiles="$(PublishDir)PixiEditor.UpdateInstaller.Exe.exe" DestinationFiles="$(PublishDir)PixiEditor.UpdateInstaller.exe"/>
     <Message Text="Renamed published executable file." Importance="high"/>
     <Message Text="Renamed published executable file." Importance="high"/>
   </Target>
   </Target>
 
 
-  <Target Name="Rename" AfterTargets="AfterBuild" Condition="'$(RuntimeIdentifier)'!='win-x64' and '$(RuntimeIdentifier)'!='win-arm64'">
+  <Target Name="RenameBuildUnix" AfterTargets="AfterBuild" Condition="'$(RuntimeIdentifier)'!='win-x64' and '$(RuntimeIdentifier)'!='win-arm64'">
     <Move SourceFiles="$(OutDir)PixiEditor.UpdateInstaller.Exe" DestinationFiles="$(OutDir)PixiEditor.UpdateInstaller"/>
     <Move SourceFiles="$(OutDir)PixiEditor.UpdateInstaller.Exe" DestinationFiles="$(OutDir)PixiEditor.UpdateInstaller"/>
     <Message Text="Renamed build executable file." Importance="high"/>
     <Message Text="Renamed build executable file." Importance="high"/>
   </Target>
   </Target>
 
 
-  <Target Name="Rename" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)'!='win-x64' and '$(RuntimeIdentifier)'!='win-arm64'">
+  <Target Name="RenamePublishUnix" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)'!='win-x64' and '$(RuntimeIdentifier)'!='win-arm64'">
     <Move SourceFiles="$(PublishDir)PixiEditor.UpdateInstaller.Exe" DestinationFiles="$(PublishDir)PixiEditor.UpdateInstaller"/>
     <Move SourceFiles="$(PublishDir)PixiEditor.UpdateInstaller.Exe" DestinationFiles="$(PublishDir)PixiEditor.UpdateInstaller"/>
     <Message Text="Renamed published executable file." Importance="high"/>
     <Message Text="Renamed published executable file." Importance="high"/>
   </Target>
   </Target>

+ 18 - 9
src/PixiEditor.UpdateModule/UpdateInstaller.cs

@@ -46,6 +46,7 @@ public class UpdateInstaller
                     log.AppendLine($"Failed to kill process {process.ProcessName} with ID {process.Id}: {ex.Message}");
                     log.AppendLine($"Failed to kill process {process.ProcessName} with ID {process.Id}: {ex.Message}");
                 }
                 }
             }
             }
+
             log.AppendLine("Processes killed.");
             log.AppendLine("Processes killed.");
         }
         }
 
 
@@ -85,10 +86,11 @@ public class UpdateInstaller
                 {
                 {
                     log.AppendLine($"Found file: {file}");
                     log.AppendLine($"Found file: {file}");
                 }
                 }
+
                 throw new FileNotFoundException("PixiEditor.app not found in the update files.");
                 throw new FileNotFoundException("PixiEditor.app not found in the update files.");
             }
             }
 
 
-            
+
             log.AppendLine($"Moving {appFile} to {TargetDirectory}");
             log.AppendLine($"Moving {appFile} to {TargetDirectory}");
             string targetAppDirectory = Path.Combine(TargetDirectory, "PixiEditor.app");
             string targetAppDirectory = Path.Combine(TargetDirectory, "PixiEditor.app");
             if (Directory.Exists(targetAppDirectory))
             if (Directory.Exists(targetAppDirectory))
@@ -96,9 +98,10 @@ public class UpdateInstaller
                 log.AppendLine($"Removing existing PixiEditor.app at {targetAppDirectory}");
                 log.AppendLine($"Removing existing PixiEditor.app at {targetAppDirectory}");
                 Directory.Delete(targetAppDirectory, true);
                 Directory.Delete(targetAppDirectory, true);
             }
             }
+
             Directory.Move(appFile, targetAppDirectory);
             Directory.Move(appFile, targetAppDirectory);
-            
-            Cleanup();
+
+            Cleanup(log);
             return;
             return;
         }
         }
 
 
@@ -128,36 +131,42 @@ public class UpdateInstaller
 
 
         log.AppendLine("Files copied");
         log.AppendLine("Files copied");
         log.AppendLine("Deleting archive and update files");
         log.AppendLine("Deleting archive and update files");
-        
-        Cleanup();
+
+        Cleanup(log);
     }
     }
 
 
-    private void Cleanup()
+    private void Cleanup(StringBuilder logger)
     {
     {
         File.Delete(ArchiveFileName);
         File.Delete(ArchiveFileName);
         Directory.Delete(UpdateFilesPath, true);
         Directory.Delete(UpdateFilesPath, true);
         string updateLocationFile = Path.Join(Path.GetTempPath(), "PixiEditor", "update-location.txt");
         string updateLocationFile = Path.Join(Path.GetTempPath(), "PixiEditor", "update-location.txt");
+        logger.AppendLine($"Looking for: {updateLocationFile}");
         if (File.Exists(updateLocationFile))
         if (File.Exists(updateLocationFile))
         {
         {
             try
             try
             {
             {
+                logger.AppendLine($"Deleting update location file: {updateLocationFile}");
                 File.Delete(updateLocationFile);
                 File.Delete(updateLocationFile);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
+                logger.AppendLine($"Failed to delete update location file: {ex.Message}");
             }
             }
         }
         }
-        
-        string updateInstallerFile = Path.Join(Path.GetTempPath(), "PixiEditor", "PixiEditor.UpdateInstaller" + (OperatingSystem.IsWindows() ? ".exe" : ""));
+
+        string updateInstallerFile = Path.Join(Path.GetTempPath(), "PixiEditor",
+            "PixiEditor.UpdateInstaller" + (OperatingSystem.IsWindows() ? ".exe" : ""));
+        logger.AppendLine($"Looking for: {updateInstallerFile}");
         if (File.Exists(updateInstallerFile))
         if (File.Exists(updateInstallerFile))
         {
         {
             try
             try
             {
             {
+                logger.AppendLine($"Deleting update installer file: {updateInstallerFile}");
                 File.Delete(updateInstallerFile);
                 File.Delete(updateInstallerFile);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                // Ignore errors during cleanup
+                logger.AppendLine($"Failed to delete update installer file: {ex.Message}");
             }
             }
         }
         }
     }
     }

+ 4 - 4
src/PixiEditor/ViewModels/SubViewModels/UpdateViewModel.cs

@@ -207,12 +207,12 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
             try
             try
             {
             {
                 UpdateState = UpdateState.Downloading;
                 UpdateState = UpdateState.Downloading;
-                if (updateCompatible)
+                if (updateCompatible || !IOperatingSystem.Current.IsWindows)
                 {
                 {
                     await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo, ZipContentType,
                     await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo, ZipContentType,
                         ZipExtension);
                         ZipExtension);
                 }
                 }
-                else if (IOperatingSystem.Current.IsWindows) // TODO: Add macos
+                else if (IOperatingSystem.Current.IsWindows)
                 {
                 {
                     await UpdateDownloader.DownloadInstaller(UpdateChecker.LatestReleaseInfo);
                     await UpdateDownloader.DownloadInstaller(UpdateChecker.LatestReleaseInfo);
                 }
                 }
@@ -299,9 +299,9 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
         {
         {
             if (Path.Exists(updaterPath))
             if (Path.Exists(updaterPath))
             {
             {
-                File.Copy(updaterPath, Path.Join(UpdateDownloader.DownloadLocation, $"PixiEditor.UpdateInstaller"),
+                File.Copy(updaterPath, Path.Join(UpdateDownloader.DownloadLocation, $"PixiEditor.UpdateInstaller" + BinaryExtension),
                     true);
                     true);
-                updaterPath = Path.Join(UpdateDownloader.DownloadLocation, $"PixiEditor.UpdateInstaller");
+                updaterPath = Path.Join(UpdateDownloader.DownloadLocation, $"PixiEditor.UpdateInstaller" + BinaryExtension);
                 File.WriteAllText(Path.Join(UpdateDownloader.DownloadLocation, "update-location.txt"),
                 File.WriteAllText(Path.Join(UpdateDownloader.DownloadLocation, "update-location.txt"),
                     Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty);
                     Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty);
             }
             }