public static void InitializeNew(bool cache, int nonencrypteddsts, int encrypteddsts) { MetadataNode vfsroot = CreateBasicVirtualFS(nonencrypteddsts + encrypteddsts); BPlusTree <byte[]> datastore = new(10); var vfsisrc = new VirtualFSInterop(vfsroot, datastore); List <ICoreDstDependencies> destinations = new(); for (int i = 0; i < nonencrypteddsts + encrypteddsts; i++) { IDstFSInterop vfsidst; if (i < nonencrypteddsts) { vfsidst = VirtualFSInterop.InitializeNewDst(vfsroot, datastore, Path.Combine("dst", i.ToString())); } else { vfsidst = VirtualFSInterop.InitializeNewDst(vfsroot, datastore, Path.Combine("dst", i.ToString()), "password"); } destinations.Add(CoreDstDependencies.InitializeNew("test", false, vfsidst, true)); } var vfsicache = VirtualFSInterop.InitializeNewDst(vfsroot, datastore, "cache"); ICoreSrcDependencies srcdeps = FSCoreSrcDependencies.InitializeNew("test", "src", vfsisrc); if (cache) { ICoreDstDependencies cachedeps = CoreDstDependencies.InitializeNew("test", true, vfsicache, false); _ = new Core(srcdeps, destinations, cachedeps); } else { _ = new Core(srcdeps, destinations); } }
private static ICoreSrcDependencies CreateNewSrc(Random random) { DateTime dateTime = CoreTest.RandomDateTime(random); MetadataNode vfsroot = new(VirtualFSInterop.MakeNewDirectoryMetadata("src", dateTime), null); BPlusTree <byte[]> datastore = new(10); CoreTest.AddStandardVFSFiles(vfsroot, datastore, random); IFSInterop srcFSInterop = new VirtualFSInterop(vfsroot, datastore); return(FSCoreSrcDependencies.InitializeNew("test", "", srcFSInterop)); }
public static void LoadCore_NewlyInitialized(bool encrypted, bool cache) { MetadataNode vfsroot = CreateBasicVirtualFS(1); BPlusTree <byte[]> datastore = new(10); var vfsisrc = new VirtualFSInterop(vfsroot, datastore); IDstFSInterop vfsidst; if (encrypted) { vfsidst = VirtualFSInterop.InitializeNewDst(vfsroot, datastore, Path.Combine("dst", "1"), "password"); } else { vfsidst = VirtualFSInterop.InitializeNewDst(vfsroot, datastore, Path.Combine("dst", "1")); } var vfsicache = VirtualFSInterop.InitializeNewDst(vfsroot, datastore, "cache"); ICoreSrcDependencies srcdeps = FSCoreSrcDependencies.InitializeNew("test", "src", vfsisrc, "cache"); ICoreDstDependencies dstdeps = CoreDstDependencies.InitializeNew("test", false, vfsidst, true); ICoreDstDependencies?cachedeps = null; if (cache) { cachedeps = CoreDstDependencies.InitializeNew("test", true, vfsicache, false); } Core core = new(srcdeps, new List <ICoreDstDependencies>() { dstdeps }, cachedeps); Assert.IsTrue(core.DefaultDstDependencies.Count == 1); vfsisrc = new VirtualFSInterop(vfsroot, datastore); if (encrypted) { vfsidst = VirtualFSInterop.LoadDst(vfsroot, datastore, Path.Combine("dst", "1"), "password"); } else { vfsidst = VirtualFSInterop.LoadDst(vfsroot, datastore, Path.Combine("dst", "1")); } vfsicache = VirtualFSInterop.LoadDst(vfsroot, datastore, "cache"); srcdeps = FSCoreSrcDependencies.Load("src", vfsisrc); dstdeps = CoreDstDependencies.Load(vfsidst, true); cachedeps = null; if (cache) { cachedeps = CoreDstDependencies.Load(vfsicache, false); } _ = new Core(srcdeps, new List <ICoreDstDependencies>() { dstdeps }, cachedeps); }
/* * int Main(string[] args) * { * return CommandLine.Parser.Default.ParseArguments<AddOptions, CommitOptions, CloneOptions>(args) * .MapResult( * (AddOptions opts) => RunAddAndReturnExitCode(opts), * (CommitOptions opts) => RunCommitAndReturnExitCode(opts), * (CloneOptions opts) => RunCloneAndReturnExitCode(opts), * errs => 1); * }*/ private static void Initialize(InitOptions opts) { try { ICoreSrcDependencies srcdep = FSCoreSrcDependencies.InitializeNew(opts.BSName, cwd, new DiskFSInterop(), opts.Cache); if (opts.Cache != null) { var cachedep = CoreDstDependencies.InitializeNew(opts.BSName, true, DiskDstFSInterop.InitializeNew(opts.Cache), false); } } catch (Exception e) { Console.WriteLine(e.Message); } }
MetadataNode vfsroot, BPlusTree <byte[]> vfsdatastore) InitializeNewCoreWithStandardFiles( int nonencrypteddsts, int encrypteddsts, Random?random = null, bool cache = true, int regFileCount = 100) { MetadataNode vfsroot = CreateBasicVirtualFS(nonencrypteddsts + encrypteddsts); BPlusTree <byte[]> vfsdatastore = new(10); MetadataNode? vfsDirectory = vfsroot.GetDirectory("src"); if (vfsDirectory == null) { throw new NullReferenceException(); } Dictionary <string, byte[]> verifyfilepaths = AddStandardVFSFiles(vfsDirectory, vfsdatastore, random, regFileCount); var vfsisrc = new VirtualFSInterop(vfsroot, vfsdatastore); List <ICoreDstDependencies> destinations = new(); for (int i = 0; i < nonencrypteddsts + encrypteddsts; i++) { IDstFSInterop vfsidst; if (i < nonencrypteddsts) { vfsidst = VirtualFSInterop.InitializeNewDst(vfsroot, vfsdatastore, Path.Combine("dst", i.ToString())); } else { vfsidst = VirtualFSInterop.InitializeNewDst(vfsroot, vfsdatastore, Path.Combine("dst", i.ToString()), "password"); } ICoreDstDependencies dstdeps = CoreDstDependencies.InitializeNew("test", false, vfsidst, cache); destinations.Add(dstdeps); } var vfsicache = VirtualFSInterop.InitializeNewDst(vfsroot, vfsdatastore, "cache"); ICoreSrcDependencies srcdeps = FSCoreSrcDependencies.InitializeNew("test", "src", vfsisrc, "cache"); ICoreDstDependencies?cachedeps = null; if (cache) { cachedeps = CoreDstDependencies.InitializeNew("test", true, vfsicache, false); } Core core = new(srcdeps, destinations, cachedeps); return(core, verifyfilepaths, vfsroot, vfsdatastore); }