PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/Raven.Database/Indexing/IndexCommitPointDirectory.cs

https://github.com/barryhagan/ravendb
C# | 55 lines | 40 code | 10 blank | 5 comment | 0 complexity | f2750b80252eaa818712a5fe380b9b6f MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause, CC-BY-SA-3.0
  1. // -----------------------------------------------------------------------
  2. // <copyright file="IndexCommitPointDirectory.cs" company="Hibernating Rhinos LTD">
  3. // Copyright (c) Hibernating Rhinos LTD. All rights reserved.
  4. // </copyright>
  5. // -----------------------------------------------------------------------
  6. using System.Globalization;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text.RegularExpressions;
  10. using Raven.Database.Extensions;
  11. namespace Raven.Database.Indexing
  12. {
  13. public class IndexCommitPointDirectory
  14. {
  15. private const string DirectoryName = "CommitPoints";
  16. private const string File = "index.commitPoint";
  17. private const string KeysToDeleteFile = "to-delete.commitPoint";
  18. public IndexCommitPointDirectory(string indexStoragePath, string directoryName, string name)
  19. {
  20. IndexFullPath = Path.Combine(indexStoragePath, directoryName);
  21. AllCommitPointsFullPath = GetAllCommitPointsFullPath(IndexFullPath);
  22. Name = name;
  23. FullPath = Path.Combine(AllCommitPointsFullPath, Name);
  24. FileFullPath = Path.Combine(FullPath, File);
  25. DeletedKeysFile = Path.Combine(FullPath, KeysToDeleteFile);
  26. }
  27. public string IndexFullPath { get; private set; }
  28. public string AllCommitPointsFullPath { get; private set; }
  29. public string Name { get; private set; }
  30. public string FullPath { get; private set; }
  31. public string FileFullPath { get; private set; }
  32. public string DeletedKeysFile { get; private set; }
  33. public static string GetAllCommitPointsFullPath(string indexFullPath)
  34. {
  35. return Path.Combine(indexFullPath, DirectoryName);
  36. }
  37. public static string[] ScanAllCommitPointsDirectory(string indexFullPath)
  38. {
  39. return
  40. Directory.GetDirectories(Path.Combine(indexFullPath, DirectoryName))
  41. .Where(x => Regex.IsMatch(Path.GetFileName(x), "^[0-9]{19,19}$"))
  42. .ToArray();
  43. }
  44. }
  45. }