UrbanCMC / PlayniteExtensions

MIT License
4 stars 2 forks source link

Added the ability to run image optimizations in a background thread. #7

Closed Zallist closed 7 months ago

Zallist commented 7 months ago

I've added a new setting in the Settings window for running image optimizations in the background. If disabled, there's basically no changes, other than some failsafe code in the OptimizeGame function which makes sure the Game being worked on is the same as the one currently in the item database.

If the background option is enabled, then a ConcurrentQueue is used to handle the optimization requests in a FIFO order. It has a backing file which it uses to make sure that it continues optimizing even if Playnite gets closed and reopened.

There's also a new Main Menu option added if optimization is currently happening, giving users the ability to cancel it.

Zallist commented 7 months ago

That is a leftover comment I forgot to strip. No, there's nothing todo on that line

On Wed, 21 Feb 2024, 08:19 UrbanCMC, @.***> wrote:

@.**** commented on this pull request.

In src/MetadataImageOptimizer/MetadataImageOptimizer.cs https://github.com/UrbanCMC/PlayniteExtensions/pull/7#discussion_r1497076066 :

@@ -121,26 +184,43 @@ private void OptimizeGame(ItemUpdateEvent change, MetadataImageOptimizerSe var coverChanged = optimizerSettings.AlwaysOptimizeOnSave || change.OldData.CoverImage != change.NewData.CoverImage; var iconChanged = optimizerSettings.AlwaysOptimizeOnSave || change.OldData.Icon != change.NewData.Icon;

  • OptimizeGame(game, optimizerSettings, backgroundChanged, coverChanged, iconChanged);
  • if (backgroundChanged || coverChanged || iconChanged)
  • {
  • if (optimizerSettings.RunInBackground)
  • {
  • // todo

Is there actually anything left to do here?

— Reply to this email directly, view it on GitHub https://github.com/UrbanCMC/PlayniteExtensions/pull/7#pullrequestreview-1892358705, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCCAX3WJVQCMVALXEFU4HLYUWUYRAVCNFSM6AAAAABDR672YCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQOJSGM2TQNZQGU . You are receiving this because you authored the thread.Message ID: @.***>