public void PutUnencrypted(string remotename, string localpath) { if (m_lastException != null) throw m_lastException; var req = new FileEntryItem(OperationType.Put, remotename, null); req.SetLocalfilename(localpath); req.Encrypted = true; //Prevent encryption req.NotTrackedInDb = true; //Prevent Db updates if (m_queue.Enqueue(req) && m_options.SynchronousUpload) { req.WaitForComplete(); if (req.Exception != null) throw req.Exception; } if (m_lastException != null) throw m_lastException; }
public void WaitForComplete(LocalDatabase db, System.Data.IDbTransaction transation) { m_db.FlushDbMessages(db, transation); if (m_lastException != null) throw m_lastException; var item = new FileEntryItem(OperationType.Terminate, null); if (m_queue.Enqueue(item)) item.WaitForComplete(); m_db.FlushDbMessages(db, transation); if (m_lastException != null) throw m_lastException; }
public IList<Library.Interface.IFileEntry> List() { if (m_lastException != null) throw m_lastException; var req = new FileEntryItem(OperationType.List, null); if (m_queue.Enqueue(req)) { req.WaitForComplete(); if (req.Exception != null) throw req.Exception; } if (m_lastException != null) throw m_lastException; return (IList<Library.Interface.IFileEntry>)req.Result; }
public void Put(VolumeWriterBase item, IndexVolumeWriter indexfile = null) { if (m_lastException != null) throw m_lastException; item.Close(); m_db.LogDbUpdate(item.RemoteFilename, RemoteVolumeState.Uploading, -1, null); var req = new FileEntryItem(OperationType.Put, item.RemoteFilename, null); req.LocalTempfile = item.TempFile; if (m_lastException != null) throw m_lastException; FileEntryItem req2 = null; // As the network link is the bottleneck, // we encrypt the dblock volume before the // upload is enqueue (i.e. on the worker thread) if (m_encryption != null) lock (m_encryptionLock) req.Encrypt(m_encryption, m_statwriter); req.UpdateHashAndSize(m_options); // We do not encrypt the dindex volume, because it is small, // and may need to be re-written if the dblock upload is retried if (indexfile != null) { m_db.LogDbUpdate(indexfile.RemoteFilename, RemoteVolumeState.Uploading, -1, null); req2 = new FileEntryItem(OperationType.Put, indexfile.RemoteFilename); req2.LocalTempfile = indexfile.TempFile; req.Indexfile = new Tuple<IndexVolumeWriter, FileEntryItem>(indexfile, req2); } if (m_queue.Enqueue(req) && m_options.SynchronousUpload) { req.WaitForComplete(); if (req.Exception != null) throw req.Exception; } if (req2 != null && m_queue.Enqueue(req2) && m_options.SynchronousUpload) { req2.WaitForComplete(); if (req2.Exception != null) throw req2.Exception; } if (m_lastException != null) throw m_lastException; }
public void GetForTesting(string remotename, long size, string hash) { if (m_lastException != null) throw m_lastException; if (hash == null) throw new InvalidOperationException("Cannot test a file without the hash"); var req = new FileEntryItem(OperationType.Get, remotename, size, hash); req.VerifyHashOnly = true; if (m_queue.Enqueue(req)) { req.WaitForComplete(); if (req.Exception != null) throw req.Exception; } if (m_lastException != null) throw m_lastException; }
public Library.Utility.TempFile Get(string remotename, long size, string hash) { if (m_lastException != null) throw m_lastException; var req = new FileEntryItem(OperationType.Get, remotename, size, hash); if (m_queue.Enqueue(req)) { req.WaitForComplete(); if (req.Exception != null) throw req.Exception; } if (m_lastException != null) throw m_lastException; return (Library.Utility.TempFile)req.Result; }
public void Delete(string remotename, long size, bool synchronous = false) { if (m_lastException != null) throw m_lastException; m_db.LogDbUpdate(remotename, RemoteVolumeState.Deleting, size, null); var req = new FileEntryItem(OperationType.Delete, remotename, size, null); if (m_queue.Enqueue(req) && synchronous) { req.WaitForComplete(); if (req.Exception != null) throw req.Exception; } if (m_lastException != null) throw m_lastException; }
public void CreateFolder(string remotename) { if (m_lastException != null) throw m_lastException; var req = new FileEntryItem(OperationType.CreateFolder, remotename); if (m_queue.Enqueue(req)) { req.WaitForComplete(); if (req.Exception != null) throw req.Exception; } if (m_lastException != null) throw m_lastException; }
public Library.Utility.TempFile GetWithInfo(string remotename, out long size, out string hash) { if (m_lastException != null) throw m_lastException; var req = new FileEntryItem(OperationType.Get, remotename, -1, null); if (m_queue.Enqueue(req)) { req.WaitForComplete(); if (req.Exception != null) throw req.Exception; } if (m_lastException != null) throw m_lastException; size = req.Size; hash = req.Hash; return (Library.Utility.TempFile)req.Result; }