Bug 493503: Ensure that icons are refreshed in the macOS Dock and Finder after updates. r=mstange,rstrong
authorStephen A Pohl <spohl.mozilla.bugs@gmail.com>
Fri, 18 Jan 2019 05:48:45 -0500
changeset 511630 76786e51becf1fa3a23f0978791a80107acf2318
parent 511629 bd29a5bac8d217c40c85a4bb90f83a34c4ff38b7
child 511631 689577cc5af1aada96523fcba4ac194ac3061d88
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, rstrong
bugs493503
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 493503: Ensure that icons are refreshed in the macOS Dock and Finder after updates. r=mstange,rstrong
toolkit/mozapps/update/updater/launchchild_osx.mm
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/mozapps/update/updater/launchchild_osx.mm
+++ b/toolkit/mozapps/update/updater/launchchild_osx.mm
@@ -105,16 +105,28 @@ LaunchMacPostProcess(const char* aAppBun
     if ([exeAsync isEqualToString:@"false"]) {
       [task waitUntilExit];
     }
   }
   // ignore the return value of the task, there's nothing we can do with it
   [task release];
 }
 
+void RefreshMacAppIcon(const char* aAppBundle)
+{
+  NSString* appBundlePath = [NSString stringWithUTF8String:aAppBundle];
+  NSDictionary* date =
+    [NSDictionary dictionaryWithObjectsAndKeys:
+      [NSDate date], NSFileModificationDate,
+      nil];
+  [[NSFileManager defaultManager] setAttributes:date
+                                   ofItemAtPath:appBundlePath
+                                          error:nil];
+}
+
 id ConnectToUpdateServer()
 {
   MacAutoreleasePool pool;
 
   id updateServer = nil;
   BOOL isConnected = NO;
   int currTry = 0;
   const int numRetries = 10; // Number of IPC connection retries before
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -72,16 +72,17 @@
 
 #if defined(XP_MACOSX)
 // These functions are defined in launchchild_osx.mm
 void CleanupElevatedMacUpdate(bool aFailureOccurred);
 bool IsOwnedByGroupAdmin(const char *aAppBundle);
 bool IsRecursivelyWritable(const char *aPath);
 void LaunchChild(int argc, const char **argv);
 void LaunchMacPostProcess(const char *aAppBundle);
+void RefreshMacAppIcon(const char* aAppBundle);
 bool ObtainUpdaterArguments(int *argc, char ***argv);
 bool ServeElevatedUpdate(int argc, const char **argv);
 void SetGroupOwnershipAndPermissions(const char *aAppBundle);
 struct UpdateServerThreadArgs {
   int argc;
   const NS_tchar **argv;
 };
 #endif
@@ -2590,16 +2591,17 @@ int LaunchCallbackAndPostProcessApps(int
         StartServiceUpdate(gInstallDirPath);
       }
     }
     EXIT_WHEN_ELEVATED(elevatedLockFilePath, updateLockFileHandle, 0);
 #elif XP_MACOSX
     if (!isElevated) {
       if (gSucceeded) {
         LaunchMacPostProcess(gInstallDirPath);
+        RefreshMacAppIcon(gInstallDirPath);
       }
 #endif
 
     LaunchCallbackApp(argv[5], argc - callbackIndex, argv + callbackIndex,
                       sUsingService);
 #ifdef XP_MACOSX
   }    // if (!isElevated)
 #endif /* XP_MACOSX */