public void UpdateKnownWebLibraryFromIntranet(string intranet_path)
        {
            Logging.Info("+Updating known Intranet Library from " + intranet_path);

            IntranetLibraryDetail intranet_library_detail = IntranetLibraryDetail.Read(IntranetLibraryTools.GetLibraryDetailPath(intranet_path));

            WebLibraryDetail new_web_library_detail = new WebLibraryDetail();

            new_web_library_detail.IntranetPath = intranet_path;
            new_web_library_detail.Id           = intranet_library_detail.Id;
            new_web_library_detail.Title        = intranet_library_detail.Title;
            new_web_library_detail.Description  = intranet_library_detail.Description;
            new_web_library_detail.IsReadOnly   = false;
            new_web_library_detail.Deleted      = false;

            UpdateKnownWebLibrary(new_web_library_detail);

            Logging.Info("-Updating known Intranet Library from " + intranet_path);
        }
        public void UpdateKnownWebLibraryFromIntranet(string intranet_path, bool suppress_flush_to_disk = true, string extra_info_message_on_skip = "")
        {
            Logging.Info("+Updating known Intranet Library from {0}", intranet_path);

            IntranetLibraryDetail intranet_library_detail = IntranetLibraryDetail.Read(IntranetLibraryTools.GetLibraryDetailPath(intranet_path));

            WebLibraryDetail new_web_library_detail = new WebLibraryDetail();

            new_web_library_detail.IntranetPath = intranet_path;
            //new_web_library_detail.IsIntranetLibrary = true;
            new_web_library_detail.Id          = intranet_library_detail.Id;
            new_web_library_detail.Title       = intranet_library_detail.Title;
            new_web_library_detail.Description = intranet_library_detail.Description;
            new_web_library_detail.IsReadOnly  = false;
            new_web_library_detail.Deleted     = false;

            UpdateKnownWebLibrary(new_web_library_detail, suppress_flush_to_disk, extra_info_message_on_skip);

            Logging.Info("-Updating known Intranet Library from {0}", intranet_path);
        }
        public void UpdateKnownWebLibraryFromIntranet(string intranet_path, bool suppress_flush_to_disk = true, string extra_info_message_on_skip = "")
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();

            Logging.Info("+Updating known Intranet Library from {0}", intranet_path);

            IntranetLibraryDetail intranet_library_detail = IntranetLibraryDetail.Read(IntranetLibraryTools.GetLibraryDetailPath(intranet_path));

            WebLibraryDetail new_web_library_detail = new WebLibraryDetail();

            new_web_library_detail.IntranetPath = intranet_path;
            new_web_library_detail.Id           = intranet_library_detail.Id;
            new_web_library_detail.Title        = intranet_library_detail.Title;
            new_web_library_detail.Description  = intranet_library_detail.Description;
            new_web_library_detail.Deleted      = false;

            UpdateKnownWebLibrary(new_web_library_detail, suppress_flush_to_disk, extra_info_message_on_skip);

            Logging.Info("-Updating known Intranet Library from {0}", intranet_path);
        }
        // *************************************************************************************************************
        // *** MIGRATION TO OPEN SOURCE CODE ***************************************************************************
        // *************************************************************************************************************
        private void AddLegacyWebLibrariesThatCanBeFoundOnDisk()
        {
            /**
             * Plan:
             * Iterate through all the folders in the Qiqqa data directory
             * If a folder contains a valid Library record and it is a WEB library, then add it to our list with the word '[LEGACY]' in front of it
             */

            string base_directory_path = UpgradePaths.V037To038.SQLiteUpgrade.BaseDirectoryForQiqqa;

            Logging.Info("Going to scan for web libraries at: {0}", base_directory_path);
            if (Directory.Exists(base_directory_path))
            {
                string[] library_directories = Directory.GetDirectories(base_directory_path);
                foreach (string library_directory in library_directories)
                {
                    Logging.Info("Inspecting directory {0} - Phase 1 : Web & Known Libraries", library_directory);

                    string databaselist_file = Path.GetFullPath(Path.Combine(library_directory, @"Qiqqa.known_web_libraries"));
                    if (File.Exists(databaselist_file))
                    {
                        LoadKnownWebLibraries(databaselist_file, true);
                    }
                }

                foreach (string library_directory in library_directories)
                {
                    Logging.Info("Inspecting directory {0} - Phase 2 : Intranet Libraries", library_directory);

                    string databaselist_file = IntranetLibraryTools.GetLibraryDetailPath(library_directory);
                    if (File.Exists(databaselist_file))
                    {
                        IntranetLibraryDetail intranet_library_detail = IntranetLibraryDetail.Read(databaselist_file);

                        UpdateKnownWebLibraryFromIntranet(library_directory, extra_info_message_on_skip: String.Format(" as obtained from file {0}", databaselist_file));
                    }
                }

                foreach (string library_directory in library_directories)
                {
                    Logging.Info("Inspecting directory {0} - Phase 3 : Bundles", library_directory);

                    // must be a qiqqa_bundle and/or qiqqa_bundle_manifest file set
                    Logging.Warn("Auto bundle import at startup is not yet suppoerted.");
                }

                foreach (string library_directory in library_directories)
                {
                    Logging.Info("Inspecting directory {0} - Phase 4 :  Local and Legacy Libraries", library_directory);

                    string database_file = Path.GetFullPath(Path.Combine(library_directory, @"Qiqqa.library"));
                    if (File.Exists(database_file))
                    {
                        var library_id = Path.GetFileName(library_directory);

                        WebLibraryDetail new_web_library_detail = new WebLibraryDetail();

                        new_web_library_detail.Id         = library_id;
                        new_web_library_detail.Title      = "Legacy Web Library - " + new_web_library_detail.Id;
                        new_web_library_detail.IsReadOnly = false;
                        // library: UNKNOWN type

                        UpdateKnownWebLibrary(new_web_library_detail);
                    }
                }
            }
        }
示例#5
0
        // *************************************************************************************************************
        // *** MIGRATION TO OPEN SOURCE CODE ***************************************************************************
        // *************************************************************************************************************
        private void AddLegacyWebLibrariesThatCanBeFoundOnDisk()
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();

            try
            {
                ConfigurationManager.ThrowWhenActionIsNotEnabled(nameof(AddLegacyWebLibrariesThatCanBeFoundOnDisk));

                /**
                 * Plan:
                 * - Iterate through all the folders in the Qiqqa data directory.
                 * - If a folder contains a valid Library record and it is a WEB library,
                 *   then add it to our list with the word '[LEGACY]' in front of it.
                 */

                string base_directory_path = UpgradePaths.V037To038.SQLiteUpgrade.BaseDirectoryForQiqqa;
                Logging.Info("Going to scan for web libraries at: {0}", base_directory_path);
                if (Directory.Exists(base_directory_path))
                {
                    string[] library_directories = Directory.GetDirectories(base_directory_path);
                    foreach (string library_directory in library_directories)
                    {
                        Logging.Info("Inspecting directory {0} - Phase 1 : Web & Known Libraries", library_directory);

                        string databaselist_file = Path.GetFullPath(Path.Combine(library_directory, @"Qiqqa.known_web_libraries"));
                        if (File.Exists(databaselist_file))
                        {
                            LoadKnownWebLibraries(databaselist_file, only_load_those_libraries_which_are_actually_present: true);
                        }
                    }

                    foreach (string library_directory in library_directories)
                    {
                        Logging.Info("Inspecting directory {0} - Phase 2 : Intranet Libraries", library_directory);

                        string databaselist_file = IntranetLibraryTools.GetLibraryDetailPath(library_directory);
                        if (File.Exists(databaselist_file))
                        {
                            IntranetLibraryDetail intranet_library_detail = IntranetLibraryDetail.Read(databaselist_file);

                            UpdateKnownWebLibraryFromIntranet(library_directory, extra_info_message_on_skip: String.Format(" as obtained from file {0}", databaselist_file));
                        }
                    }

                    foreach (string library_directory in library_directories)
                    {
                        Logging.Info("Inspecting directory {0} - Phase 3 : Bundles", library_directory);

                        // must be a qiqqa_bundle and/or qiqqa_bundle_manifest file set
                        Logging.Warn("Auto bundle import at startup is not yet supported.");
                    }

                    foreach (string library_directory in library_directories)
                    {
                        Logging.Info("Inspecting directory {0} - Phase 4 : Local and Legacy Libraries", library_directory);

                        string database_file   = LibraryDB.GetLibraryDBPath(library_directory);
                        string db_syncref_path = IntranetLibraryTools.GetLibraryMetadataPath(library_directory);

                        // add/update only if this is not a Internet sync directory/DB!
                        if (File.Exists(db_syncref_path))
                        {
                            Logging.Info("Skip the Qiqqa Internet/Intranet Sync directory and the sync DB contained therein: '{0}'", db_syncref_path);

                            // https://github.com/jimmejardine/qiqqa-open-source/issues/145 :: delete lib file when it is very small and was illegally
                            // constructed by a previous v82beta Qiqqa release:
                            if (File.Exists(database_file))
                            {
                                long s3length = File.GetSize(database_file);
                                if (6 * 1024 > s3length)
                                {
                                    Logging.Warn("DELETE the wrongfully created DB file '{0}' in the Qiqqa Internet/Intranet Sync directory and the sync DB contained therein: '{1}', which has precedence!", database_file, db_syncref_path);

                                    FileTools.DeleteToRecycleBin(database_file);
                                }
                                else
                                {
                                    Logging.Error("Inspect the Library DB file '{0}' in the Qiqqa Internet/Intranet Sync directory and the sync DB contained therein: '{1}', which MAY have precedence. Delete one of these manually to clean up your system as Qiqqa heuristics cannot tell which is the prevalent metadata database here!", database_file, db_syncref_path);
                                }
                            }

                            continue;
                        }
                        if (File.Exists(database_file))
                        {
                            var library_id = Path.GetFileName(library_directory);

                            WebLibraryDetail new_web_library_detail = new WebLibraryDetail();

                            new_web_library_detail.Id         = library_id;
                            new_web_library_detail.Title      = "Legacy Web Library - " + new_web_library_detail.Id;
                            new_web_library_detail.IsReadOnly = false;
                            // library: UNKNOWN type

                            UpdateKnownWebLibrary(new_web_library_detail);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.Error(ex, "There was a problem while scanning for (legacy) libraries.");
            }
        }