/// <summary> /// Delete a file inside datafile and all metadata related /// </summary> public bool Delete(string id) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException("id"); } // remove file reference in _files var d = _engine.Delete(FILES, Query.EQ("_id", id)); // if not found, just return false if (d == 0) { return(false); } var index = 0; while (true) { var del = _engine.Delete(CHUNKS, Query.EQ("_id", LiteFileInfo.GetChunckId(id, index++))); if (del == 0) { break; } } return(true); }
private byte[] GetChunkData(int index) { // check if there is no more chunks in this file var chunk = _engine .Find(LiteFileStorage.CHUNKS, Query.EQ("_id", LiteFileInfo.GetChunckId(_file.Id, index))) .FirstOrDefault(); // if chunk is null there is no more chunks return(chunk == null ? null : chunk["data"].AsBinary); }