public NeoVirtFS(IMongoDatabase db) { this.db = db; // Get wired up to our collections NeoVirtFSCol = db.NeoVirtFS(); NeoVirtFSDeletedCol = db.NeoVirtFSDeleted(); //NeoVirtFSNamespacesCol = db.NeoVirtFSNamespaces(); //NeoVirtFSVolumesCol = db.NeoVirtFSVolumes(); //NeoVirtFSSecPrincipalsCol = db.NeoVirtFSSecPrincipals(); //NeoVirtFSSecACLsCol = db.NeoVirtFSSecACLs(); bac = db.BakedAssets(); bvol = db.BakedVolumes(); if (nodeCache == null) // Some other instance might have done this { var oa = new MemoryCacheOptions() { // SizeLimit = 100 * 1024 * 1024 }; // 100 mb? nodeCache = new MemoryCache(oa); } var HaveRoot = NeoAssets.Mongo.NeoVirtFS.PullNamespacesAndVolumes(db, ref NamespaceNames, ref Namespaces, ref RootNameSpace); if (!HaveRoot) { throw new Exception("Did not define a root namespace"); } }
//ulong real_position = 0; //ulong decomp_position = 0; public AssetFile(string subpath, IMongoDatabase db, IMongoCollection <BakedAssets> bac, IMongoCollection <BakedVolumes> bVol = null) { this.db = db; this.bac = bac; this.subpath = subpath.ToLowerInvariant(); // These come in upper case occasionally // We may want to enforce a file heirarchy here, but for not just need an // asset record to match (key is simply the sha1 in lower case and text) var theFilter = Builders <BakedAssets> .Filter.Eq("_id", this.subpath); baRec = bac.FindSync(theFilter).FirstOrDefault(); // This file could conceivably exist as an unanneled file but we would // need a different abstraction here to read it -- we can generate a different // Stream, but we will need a different file service // Also this scheme needs access controls if (baRec == null) { Console.WriteLine($"Can't file BakedAsset: _id: {this.subpath}"); return; } var vCol = bVol; if (vCol == null) { vCol = db.BakedVolumes(); } try { var volFilter = Builders <BakedVolumes> .Filter.Eq("_id", baRec.Volume); volRec = vCol.FindSync(volFilter).FirstOrDefault(); } catch (Exception ex) { Console.WriteLine($"Error: ${ex.Message}"); } unBaker = new UnbakeContext(db, volRec, baRec); //var channel = GrpcChannel.ForAddress("http://feanor:5000"); //assetClient = new BakedVolumeData.BakedVolumeDataClient(channel); }