protected void RenameDirectory(string oldFullPath, string newFullPath) { // make sure we've got the full paths oldFullPath = PathHelper.GetFullPath(oldFullPath); newFullPath = PathHelper.GetFullPath(newFullPath); WikiEntry entry; if (UnderlyingModel.UnsafeTryGetAssetBySourcePath(oldFullPath, out entry)) { var visitor = new RenameVisitor( oldFullPath, newFullPath, (oldSourcePath, oldWikiPath, oldWikiUrl, page) => { HandlePageMoved(page, oldSourcePath, oldWikiPath, oldWikiUrl); }, (oldSourcePath, oldWikiPath, oldWikiUrl, directory) => { HandleDirectoryMoved(directory, oldSourcePath, oldWikiPath, oldWikiUrl); }); entry.Accept(visitor); } }
protected void RenamePage(string oldFullPath, string newFullPath) { // make sure we've got the full paths oldFullPath = PathHelper.GetFullPath(oldFullPath); newFullPath = PathHelper.GetFullPath(newFullPath); // it's possible that the file rename could bring the file // into scope (i.e. if the file extension changes) // in that case this is just an add WikiEntry entry; if (UnderlyingModel.UnsafeTryGetAssetBySourcePath(oldFullPath, out entry)) { if (newFullPath.EndsWith(fileExtension)) { var visitor = new RenameVisitor( oldFullPath, newFullPath, (oldSourcePath, oldWikiPath, oldWikiUrl, page) => { HandlePageMoved(page, oldSourcePath, oldWikiPath, oldWikiUrl); }); entry.Accept(visitor); } else { // we've changed to a non-relevant extension, delete DeletePage(oldFullPath); } } else if (Path.GetExtension(newFullPath).Equals(fileExtension, StringComparison.InvariantCultureIgnoreCase)) { // and its only an add if the extension is correct (just in case we have // been renamed from (for example) .md to .txt AddPage(newFullPath); } }