mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-07-28 01:59:03 +02:00
Move cookie import code to ExportManager
This commit is contained in:
parent
f7dc200684
commit
aa2c60f7e9
@ -8,8 +8,8 @@
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Export{
|
||||
sealed class ExportManager{
|
||||
public static readonly string CookiesPath = Path.Combine(Program.StoragePath, "Cookies");
|
||||
public static readonly string TempCookiesPath = Path.Combine(Program.StoragePath, "CookiesTmp");
|
||||
private static readonly string CookiesPath = Path.Combine(Program.StoragePath, "Cookies");
|
||||
private static readonly string TempCookiesPath = Path.Combine(Program.StoragePath, "CookiesTmp");
|
||||
|
||||
public bool IsRestarting { get; private set; }
|
||||
public Exception LastException { get; private set; }
|
||||
@ -125,6 +125,20 @@ public bool Import(){
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportCookies(){
|
||||
if (File.Exists(TempCookiesPath)){
|
||||
try{
|
||||
if (File.Exists(CookiesPath)){
|
||||
File.Delete(CookiesPath);
|
||||
}
|
||||
|
||||
File.Move(TempCookiesPath, CookiesPath);
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Profile Import Error", "Could not import the cookie file to restore login session.", true, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<PathInfo> EnumerateFilesRelative(string root){
|
||||
return Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories).Select(fullPath => new PathInfo{
|
||||
Full = fullPath,
|
||||
|
12
Program.cs
12
Program.cs
@ -109,16 +109,8 @@ private static void Main(){
|
||||
}
|
||||
}
|
||||
|
||||
if (programArguments.Contains("-importcookies") && File.Exists(ExportManager.TempCookiesPath)){
|
||||
try{
|
||||
if (File.Exists(ExportManager.CookiesPath)){
|
||||
File.Delete(ExportManager.CookiesPath);
|
||||
}
|
||||
|
||||
File.Move(ExportManager.TempCookiesPath, ExportManager.CookiesPath);
|
||||
}catch(Exception e){
|
||||
Reporter.HandleException("Profile Import Error", "Could not import the cookie file to restore login session.", true, e);
|
||||
}
|
||||
if (programArguments.Contains("-importcookies")){
|
||||
ExportManager.ImportCookies();
|
||||
}
|
||||
|
||||
BrowserCache.ClearOldCacheFiles();
|
||||
|
Loading…
Reference in New Issue
Block a user