Example #1
0
        public void Load()
        {
            lock (downloadQueue)
            {
                try
                {
                    if (File.Exists(DATA_FOLDER + saveLocation))
                    {
                        var saved = SafeLoad <Model>(saveLocation);

                        Shares.Clear();
                        Shares.AddRange(saved.Shares.OrderBy(s => s.Name).ToList());
                        Avatar                = saved.Avatar;
                        Description           = saved.Description;
                        Nickname              = saved.Nickname;
                        DownloadFolder        = saved.DownloadFolder;
                        MaxDownloads          = saved.MaxDownloads;
                        MaxDownloadsPerUser   = saved.MaxDownloadsPerUser;
                        MaxUploads            = saved.MaxUploads;
                        MaxUploadsPerUser     = saved.MaxUploadsPerUser;
                        DisableComparision    = saved.DisableComparision;
                        LocalNode             = saved.LocalNode;
                        AlwaysNoCacheBrowsing = saved.AlwaysNoCacheBrowsing;
                        OverlordPriority      = saved.OverlordPriority;
                        DisplayedHelp         = saved.DisplayedHelp;
                    }
                    else if (File.Exists(Legacy.Model.saveLocation))
                    {
                        //New config doesnt exist but an older version does, try to import.
                        var oldmodel = new Legacy.Model();
                        oldmodel.Load();

                        Shares.Clear();
                        Shares.AddRange(oldmodel.Shares.OrderBy(s => s.Name).ToList());
                        Avatar              = oldmodel.Avatar;
                        Description         = oldmodel.Description;
                        Nickname            = oldmodel.Nickname;
                        DownloadFolder      = oldmodel.DownloadFolder;
                        MaxDownloads        = oldmodel.MaxDownloads;
                        MaxDownloadsPerUser = oldmodel.MaxDownloadsPerUser;
                        MaxUploads          = oldmodel.MaxUploads;
                        MaxUploadsPerUser   = oldmodel.MaxUploadsPerUser;
                        DisableComparision  = oldmodel.DisableComparision;
                        LocalNode           = new Node();
                        foreach (var data in oldmodel.Node.Data)
                        {
                            LocalNode.SetData(data.Key, data.Value);
                        }
                        AlwaysNoCacheBrowsing = oldmodel.AlwaysNoCacheBrowsing;
                        OverlordPriority      = OverlordPriority.Normal;
                        Save();
                    }
                }
                catch (Exception e)
                {
                    LogManager.GetLogger("faplog").Warn("Failed to read config", e);
                }
            }
        }
Example #2
0
        public void Load()
        {
            lock (downloadQueue)
            {
                try
                {
                    if (File.Exists(DATA_FOLDER + saveLocation))
                    {
                        var saved = SafeLoad<Model>(saveLocation);

                        Shares.Clear();
                        Shares.AddRange(saved.Shares.OrderBy(s => s.Name).ToList());
                        Avatar = saved.Avatar;
                        Description = saved.Description;
                        Nickname = saved.Nickname;
                        DownloadFolder = saved.DownloadFolder;
                        MaxDownloads = saved.MaxDownloads;
                        MaxDownloadsPerUser = saved.MaxDownloadsPerUser;
                        MaxUploads = saved.MaxUploads;
                        MaxUploadsPerUser = saved.MaxUploadsPerUser;
                        DisableComparision = saved.DisableComparision;
                        LocalNode = saved.LocalNode;
                        AlwaysNoCacheBrowsing = saved.AlwaysNoCacheBrowsing;
                        OverlordPriority = saved.OverlordPriority;
                        DisplayedHelp = saved.DisplayedHelp;
                    }
                    else if (File.Exists(Legacy.Model.saveLocation))
                    {
                        //New config doesnt exist but an older version does, try to import.
                        var oldmodel = new Legacy.Model();
                        oldmodel.Load();

                        Shares.Clear();
                        Shares.AddRange(oldmodel.Shares.OrderBy(s => s.Name).ToList());
                        Avatar = oldmodel.Avatar;
                        Description = oldmodel.Description;
                        Nickname = oldmodel.Nickname;
                        DownloadFolder = oldmodel.DownloadFolder;
                        MaxDownloads = oldmodel.MaxDownloads;
                        MaxDownloadsPerUser = oldmodel.MaxDownloadsPerUser;
                        MaxUploads = oldmodel.MaxUploads;
                        MaxUploadsPerUser = oldmodel.MaxUploadsPerUser;
                        DisableComparision = oldmodel.DisableComparision;
                        LocalNode = new Node();
                        foreach (var data in oldmodel.Node.Data)
                            LocalNode.SetData(data.Key, data.Value);
                        AlwaysNoCacheBrowsing = oldmodel.AlwaysNoCacheBrowsing;
                        OverlordPriority = OverlordPriority.Normal;
                        Save();
                    }
                }
                catch (Exception e)
                {
                    LogManager.GetLogger("faplog").Warn("Failed to read config", e);
                }
            }
        }