public void TreeLock_TSQL_Underscore() { // This test makes sure that it does not cause a problem if a path // contains an underscore. Previously this did not work correctly // because the SQL LIKE operator treated it as a special character. Test <object>(() => { using (TreeLock.Acquire("/Root/A/BxB/C")) { TreeLock.AssertFree("/Root/A/B_B"); using (TreeLock.Acquire("/Root/A/B_B")) { TreeLock.AssertFree("/Root/A/B_"); TreeLock.AssertFree("/Root/A/ByB"); } var thrown = false; try { TreeLock.AssertFree("/Root/A/BxB"); } catch (LockedTreeException) { thrown = true; } Assert.IsTrue(thrown, "#1"); return(null); } }); }
private void RebuildIndex_NoRecursive(Node node, bool databaseAndIndex) { TreeLock.AssertFree(node.Path); var head = NodeHead.Get(node.Id); bool hasBinary; if (databaseAndIndex) { foreach (var version in head.Versions.Select(v => Node.LoadNodeByVersionId(v.VersionId))) { DataBackingStore.SaveIndexDocument(version, false, false, out hasBinary); } } var versioningInfo = new VersioningInfo { LastDraftVersionId = head.LastMinorVersionId, LastPublicVersionId = head.LastMajorVersionId, Delete = new int[0], Reindex = new int[0] }; CreateActivityAndExecute(IndexingActivityType.Rebuild, node.Path, node.Id, 0, 0, null, versioningInfo, null); }
public void RebuildIndex(Node node, bool recursive = false, IndexRebuildLevel rebuildLevel = IndexRebuildLevel.IndexOnly) { // do nothing in case of IndexOnly level, because this is a NULL populator if (rebuildLevel == IndexRebuildLevel.IndexOnly) { return; } using (var op = SnTrace.Index.StartOperation("NullPopulator.RefreshIndex. Version: {0}, VersionId: {1}, recursive: {2}, level: {3}", node.Version, node.VersionId, recursive, rebuildLevel)) { using (new Storage.Security.SystemAccount()) { if (recursive) { using (TreeLock.Acquire(node.Path)) { foreach (var n in NodeEnumerator.GetNodes(node.Path)) { DataBackingStore.SaveIndexDocument(n, false, false, out _); } } } else { TreeLock.AssertFree(node.Path); DataBackingStore.SaveIndexDocument(node, false, false, out _); } } op.Successful = true; } }
private bool IsLocked(string path) { try { TreeLock.AssertFree(path); return(false); } catch (LockedTreeException) { return(true); } }