Ejemplo n.º 1
0
        /// <summary>
        /// Acknowledge a handle was processed and remove from queue.
        /// </summary>
        /// <param name="handle">handle received from Get()</param>
        /// <exception cref="ArgumentNullException">handle is null</exception>
        public void Ack(Handle handle)
        {
            if (handle == null)
            {
                throw new ArgumentNullException("handle");
            }

            collection.Remove(new QueryDocument("_id", handle.Id));

            foreach (var stream in handle.Streams)
            {
                stream.Value.Dispose();
                gridfs.DeleteById(stream.Key);
            }
        }
Ejemplo n.º 2
0
        public void TestDeleteByFileId()
        {
            _gridFS.Delete(Query.Null);
            Assert.AreEqual(0, _gridFS.Chunks.Count());
            Assert.AreEqual(0, _gridFS.Files.Count());

            var fileInfo = UploadHelloWorld();

            Assert.AreEqual(1, _gridFS.Chunks.Count());
            Assert.AreEqual(1, _gridFS.Files.Count());

            _gridFS.DeleteById(fileInfo.Id);
            Assert.AreEqual(0, _gridFS.Chunks.Count());
            Assert.AreEqual(0, _gridFS.Files.Count());
        }
Ejemplo n.º 3
0
        public void DeleteDirectory(string virtualPath)
        {
            string      fixedPath   = FixPath(virtualPath);
            MongoGridFS mongoGridFs = GetGridFS();
            var         fileInfos   = mongoGridFs.Find(Query.Matches("metadata.directory_name", new BsonRegularExpression(new Regex(@"^" + fixedPath))));

            foreach (var fi in fileInfos)
            {
                mongoGridFs.DeleteById(fi.Id);
            }

            mongoGridFs.Delete(fixedPath);

            if (DirectoryDeleted != null)
            {
                DirectoryDeleted.Invoke(this, new FileEventArgs(virtualPath, null));
            }
        }