Esempio n. 1
0
        public BackendHandler(Options options, string backendUrl, DatabaseCommon database, StatsCollector stats, ITaskReader taskreader)
            : base()
        {
            m_backendurl = backendUrl;
            m_database   = database;
            m_options    = options;
            m_backendurl = backendUrl;
            m_stats      = stats;
            m_taskreader = taskreader;
            m_backend    = DynamicLoader.BackendLoader.GetBackend(backendUrl, options.RawOptions);

            var shortname = m_backendurl;

            // Try not to leak hostnames or other information in the error messages
            try { shortname = new Library.Utility.Uri(shortname).Scheme; }
            catch { }

            if (m_backend == null)
            {
                throw new Duplicati.Library.Interface.UserInformationException(string.Format("Backend not supported: {0}", shortname), "BackendNotSupported");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an index volume with the temporary contents
        /// </summary>
        /// <returns>The index volume.</returns>
        /// <param name="blockfilename">The name of the block file.</param>
        /// <param name="blockHash">Hash of the volume</param>
        /// <param name="blockSize">Size of the volume</param>
        public async Task <IndexVolumeWriter> CreateVolume(string blockfilename, string blockHash, long blockSize, Options options, DatabaseCommon database)
        {
            var w = new IndexVolumeWriter(options);

            w.VolumeID = await database.RegisterRemoteVolumeAsync(w.RemoteFilename, RemoteVolumeType.Index, RemoteVolumeState.Temporary);

            w.StartVolume(blockfilename);
            foreach (var n in blockHashes)
            {
                var args = n.Split(new char[] { ':' }, 2);
                w.AddBlock(args[1], long.Parse(args[0]));
            }

            w.FinishVolume(blockHash, blockSize);

            var enumerator = blockListHashes.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var hash = enumerator.Current;
                enumerator.MoveNext();
                var data = Convert.FromBase64String(enumerator.Current);

                w.WriteBlocklist(hash, data, 0, data.Length);
            }

            w.Close();

            return(w);
        }