mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-25 17:34:06 +02:00
Fix and finish migration (refresh desktop, protect copying and deletion)
This commit is contained in:
parent
65d1201bbb
commit
6a03730496
@ -26,7 +26,7 @@ public static void Run(){
|
|||||||
formWait.ShowWorkDialog(() => {
|
formWait.ShowWorkDialog(() => {
|
||||||
if (!BeginMigration(decision,ex => formWait.Invoke(new Action(() => {
|
if (!BeginMigration(decision,ex => formWait.Invoke(new Action(() => {
|
||||||
if (ex != null){
|
if (ex != null){
|
||||||
MessageBox.Show(ex.Message); // TODO
|
MessageBox.Show(ex.ToString()); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
formWait.Close();
|
formWait.Close();
|
||||||
@ -65,16 +65,6 @@ private static bool BeginMigration(MigrationDecision decision, Action<Exception>
|
|||||||
CopyFile("Local Storage"+Path.DirectorySeparatorChar+"https_tweetdeck.twitter.com_0.localstorage-journal");
|
CopyFile("Local Storage"+Path.DirectorySeparatorChar+"https_tweetdeck.twitter.com_0.localstorage-journal");
|
||||||
|
|
||||||
if (decision == MigrationDecision.Migrate || decision == MigrationDecision.MigratePurge){
|
if (decision == MigrationDecision.Migrate || decision == MigrationDecision.MigratePurge){
|
||||||
Directory.Delete(TweetDeckPath,true);
|
|
||||||
|
|
||||||
try{
|
|
||||||
Directory.Delete(TweetDeckPathParent,false);
|
|
||||||
}catch(IOException){
|
|
||||||
// most likely not empty, ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (decision == MigrationDecision.MigratePurge){
|
|
||||||
// kill process if running
|
// kill process if running
|
||||||
Process runningProcess = ProgramProcessSearch.FindProcessWithWindowByName("TweetDeck");
|
Process runningProcess = ProgramProcessSearch.FindProcessWithWindowByName("TweetDeck");
|
||||||
|
|
||||||
@ -89,6 +79,25 @@ private static bool BeginMigration(MigrationDecision decision, Action<Exception>
|
|||||||
runningProcess.Close();
|
runningProcess.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete folders
|
||||||
|
for(int wait = 0; wait < 50; wait++){
|
||||||
|
try{
|
||||||
|
Directory.Delete(TweetDeckPath,true);
|
||||||
|
break;
|
||||||
|
}catch(Exception){
|
||||||
|
// browser subprocess not ended yet, wait
|
||||||
|
Thread.Sleep(300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
Directory.Delete(TweetDeckPathParent,false);
|
||||||
|
}catch(IOException){
|
||||||
|
// most likely not empty, ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decision == MigrationDecision.MigratePurge){
|
||||||
// update the lnk files wherever possible (desktop icons, pinned taskbar)
|
// update the lnk files wherever possible (desktop icons, pinned taskbar)
|
||||||
string[] locations = {
|
string[] locations = {
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||||
@ -110,6 +119,8 @@ private static bool BeginMigration(MigrationDecision decision, Action<Exception>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Program.SHChangeNotify(0x8000000,0x1000,IntPtr.Zero,IntPtr.Zero); // refreshes desktop
|
||||||
|
|
||||||
// uninstall in the background
|
// uninstall in the background
|
||||||
string guid = ProgramRegistrySearch.FindByDisplayName("TweetDeck");
|
string guid = ProgramRegistrySearch.FindByDisplayName("TweetDeck");
|
||||||
|
|
||||||
@ -132,7 +143,11 @@ private static bool BeginMigration(MigrationDecision decision, Action<Exception>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void CopyFile(string relativePath){
|
private static void CopyFile(string relativePath){
|
||||||
File.Copy(Path.Combine(TweetDeckPath,relativePath),Path.Combine(Program.StoragePath,relativePath),true);
|
try{
|
||||||
|
File.Copy(Path.Combine(TweetDeckPath,relativePath),Path.Combine(Program.StoragePath,relativePath),true);
|
||||||
|
}catch(FileNotFoundException){
|
||||||
|
}catch(DirectoryNotFoundException){
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,9 @@ static Program(){
|
|||||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||||
public static extern IntPtr LoadLibrary(string name);
|
public static extern IntPtr LoadLibrary(string name);
|
||||||
|
|
||||||
|
[DllImport("Shell32.dll")]
|
||||||
|
public static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
private static void Main(){
|
private static void Main(){
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
|
Loading…
Reference in New Issue
Block a user