Exemple #1
0
        /// <summary>
        /// Recursively re-indexes all the contents of the old (renamed) directory to the new one.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="oldDirectory">The old directory.</param>
        /// <param name="newDirectory">The new directory.</param>
        private static void ReindexDirectory(IFilesStorageProviderV60 provider, string oldDirectory, string newDirectory)
        {
            oldDirectory = NormalizeFullPath(oldDirectory);
            newDirectory = NormalizeFullPath(newDirectory);

            // At this point the directory has been already renamed,
            // thus we must list on the new directory and construct the old name
            // Example: /directory/one/ renamed to /directory/two-two/
            // List on /directory/two-two/
            //     dir1
            //     dir2
            // oldSub = /directory/one/dir1/

            foreach (string sub in provider.ListDirectories(newDirectory))
            {
                string oldSub = oldDirectory + sub.Substring(newDirectory.Length);
                ReindexDirectory(provider, oldSub, sub);
            }

            foreach (string file in provider.ListFiles(newDirectory))
            {
                string oldFile = oldDirectory + file.Substring(newDirectory.Length);
                SearchClass.RenameFile(provider.CurrentWiki, provider.GetType().FullName + "|" + oldFile, provider.GetType().FullName + "|" + file);
            }
        }
Exemple #2
0
        /// <summary>
        /// Deletes the permissions of a directory.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="directory">The directory.</param>
        private static void DeletePermissions(IFilesStorageProviderV60 provider, string directory)
        {
            directory = NormalizeFullPath(directory);

            foreach (string sub in provider.ListDirectories(directory))
            {
                DeletePermissions(provider, sub);
            }

            AuthWriter authWriter = new AuthWriter(Collectors.CollectorsBox.GetSettingsProvider(provider.CurrentWiki));

            authWriter.ClearEntriesForDirectory(provider, directory);
        }
Exemple #3
0
        /// <summary>
        /// De-indexes all contents of a directory.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="directory">The directory.</param>
        private static void DeindexDirectory(IFilesStorageProviderV60 provider, string directory)
        {
            directory = NormalizeFullPath(directory);

            foreach (string sub in provider.ListDirectories(directory))
            {
                DeindexDirectory(provider, sub);
            }

            foreach (string file in provider.ListFiles(directory))
            {
                SearchClass.UnindexFile(provider.GetType().FullName + "|" + file, provider.CurrentWiki);
            }
        }
Exemple #4
0
        /// <summary>
        /// Recursively moves permissions from the old (renamed) directory to the new one.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="oldDirectory">The old directory.</param>
        /// <param name="newDirectory">The new directory.</param>
        private static void MovePermissions(IFilesStorageProviderV60 provider, string oldDirectory, string newDirectory)
        {
            oldDirectory = NormalizeFullPath(oldDirectory);
            newDirectory = NormalizeFullPath(newDirectory);

            // At this point the directory has been already renamed,
            // thus we must list on the new directory and construct the old name
            // Example: /directory/one/ renamed to /directory/two-two/
            // List on /directory/two-two/
            //     dir1
            //     dir2
            // oldSub = /directory/one/dir1/

            foreach (string sub in provider.ListDirectories(newDirectory))
            {
                string oldSub = oldDirectory + sub.Substring(newDirectory.Length);
                MovePermissions(provider, oldSub, sub);
            }

            AuthWriter authWriter = new AuthWriter(Collectors.CollectorsBox.GetSettingsProvider(provider.CurrentWiki));

            authWriter.ClearEntriesForDirectory(provider, newDirectory);
            authWriter.ProcessDirectoryRenaming(provider, oldDirectory, newDirectory);
        }