/// <summary> /// Constructor for encryption module interface /// </summary> public DynamicModule(Duplicati.Library.Interface.IEncryption module) { this.Key = module.FilenameExtension; this.Description = module.Description; this.DisplayName = module.DisplayName; if (module.SupportedCommands != null) { this.Options = module.SupportedCommands.ToArray(); } }
private static void PrintEncryptionModule(Duplicati.Library.Interface.IEncryption mod, List<string> lines) { lines.Add(mod.DisplayName + " (." + mod.FilenameExtension + "):"); lines.Add(" " + mod.Description); if (mod.SupportedCommands != null && mod.SupportedCommands.Count > 0) { lines.Add(" " + Strings.Program.SupportedOptionsHeader); foreach (Library.Interface.ICommandLineArgument arg in mod.SupportedCommands) Library.Interface.CommandLineArgument.PrintArgument(lines, arg, " "); } lines.Add(""); }
/// <summary> /// Internal helper to consistenly name remote files beyond what the filenamestrategy supports /// </summary> /// <param name="remote">The entry to create a filename for</param> /// <returns>A filename with extensions</returns> public string GenerateFilename(BackupEntryBase remote) { string remotename = m_filenamestrategy.GenerateFilename(remote); if (remote is ManifestEntry) remotename += ".manifest"; else if (remote is VerificationEntry) return remotename; else if (!(remote is DeleteTransactionEntry)) remotename += "." + m_options.CompressionModule; if (!m_options.NoEncryption) { if (m_encryption == null) m_encryption = DynamicLoader.EncryptionLoader.GetModule(m_options.EncryptionModule, m_options.Passphrase, m_options.RawOptions); remotename += "." + m_encryption.FilenameExtension; } return remotename; }
private void Put(BackupEntryBase remote, string filename, bool forcesync) { if (!remote.IsEncrypted && !m_options.NoEncryption && remote as VerificationEntry == null) { if (m_encryption == null) m_encryption = DynamicLoader.EncryptionLoader.GetModule(m_options.EncryptionModule, m_options.Passphrase, m_options.RawOptions); using (Utility.TempFile raw = new Duplicati.Library.Utility.TempFile(filename)) using (Utility.TempFile enc = new Duplicati.Library.Utility.TempFile()) { m_encryption.Encrypt(raw, enc); filename = enc; enc.Protected = true; raw.Protected = false; } remote.IsEncrypted = true; } remote.RemoteHash = Utility.Utility.CalculateHash(filename); remote.Filename = GenerateFilename(remote); remote.Filesize = new System.IO.FileInfo(filename).Length; if (!m_async) PutInternal(remote, filename); else { if (forcesync) { int count; lock (m_queuelock) count = m_pendingOperations.Count; while (count > 0) { m_asyncItemProcessed.WaitOne(1000 * 5, false); lock (m_queuelock) count = m_pendingOperations.Count; } PutInternal(remote, filename); } else { bool waitForCompletion; //There are 3 files in a volume (signature, content and manifest) + a verification file int uploads_in_set = m_options.CreateVerificationFile ? 4 : 3; lock (m_queuelock) { if (m_workerException != null) throw m_workerException; m_pendingOperations.Enqueue(new KeyValuePair<BackupEntryBase, string>(remote, filename)); m_asyncItemReady.Set(); waitForCompletion = m_options.AsynchronousUploadLimit > 0 && m_pendingOperations.Count > (m_options.AsynchronousUploadLimit * uploads_in_set); } while (waitForCompletion) { m_asyncItemProcessed.WaitOne(1000 * 5, false); lock (m_queuelock) { if (m_workerException != null) throw m_workerException; waitForCompletion = m_options.AsynchronousUploadLimit > 0 && m_pendingOperations.Count > (m_options.AsynchronousUploadLimit * uploads_in_set); } } } } }