private void AddArchiveSource(string sourceArchive, string sourceFile, string destinationPath, string hash, long size) { lock (_archiveFiles) { _destFiles.Add(new DestinationFileInfo(destinationPath, hash)); // see if we already have this file in the archive/external ArchiveSource existing = null; if (_archiveFiles.TryGetValue(hash, out existing)) { // if we have raw source file, prefer that over a zipped source file if (sourceArchive == null && existing.SourceArchive != null) { existing.SourceArchive = null; existing.SourceFile = sourceFile; } } else { var archivePath = Path.Combine(hash, Path.GetFileName(destinationPath)); _archiveFiles.Add(hash, new ArchiveSource(sourceArchive, sourceFile, archivePath, hash, size)); } } }
public void AddExternalFile(string externalFile) { CheckDisposed(); using (var fs = File.OpenRead(externalFile)) { string hash = GetHash(fs); // $ prefix indicates that the file is not in the archive and path is relative to an external directory _archiveFiles[hash] = new ArchiveSource(null, null, "$" + hash, hash, fs.Length); _externalFiles[hash] = externalFile; } }
/// <summary> /// Selects the source. /// </summary> /// <returns>The source.</returns> /// <param name="paramId">Parameter identifier.</param> public ArchiveSource SelectSource (long paramId) { string query = string.Format("SELECT * FROM archivesource WHERE Id = '{0}'", paramId); var source = new ArchiveSource (); if (connection.State != ConnectionState.Open) { this.OpenConnection (); } MySqlCommand cmd = new MySqlCommand (query, connection); MySqlDataReader dataReader = cmd.ExecuteReader (); if (dataReader.HasRows) { while (dataReader.Read ()) { source.GetArchiveSource (dataReader); } } dataReader.Close (); this.CloseConnection (); return source; }
public void AddExternalFile(string externalFile) { CheckDisposed(); using (var fs = File.OpenRead(externalFile)) { string hash = GetHash(fs); // $ prefix indicates that the file is not in the archive and path is relative to an external directory _archiveFiles[hash] = new ArchiveSource(null, null, "$" + hash , hash, fs.Length); _externalFiles[hash] = externalFile; } }
/// <summary> /// Selects the ArchiveSource /// </summary> /// <returns>The sources.</returns> /// <param name="paramTop">Parameter top.</param> public IList <ArchiveSource> SelectSources (string paramTop) { string query = "SELECT " + paramTop + " FROM archivesource"; this.SourceList = new List<ArchiveSource> (); if (connection.State != ConnectionState.Open) { this.OpenConnection (); } MySqlCommand cmd = new MySqlCommand (query, connection); MySqlDataReader dataReader = cmd.ExecuteReader (); if (dataReader.HasRows) { while (dataReader.Read ()) { var source = new ArchiveSource (); source.GetArchiveSource (dataReader); this.SourceList.Add (source); } } dataReader.Close (); this.CloseConnection (); return this.SourceList; }
/// <summary> /// Gets the source by identifier. /// </summary> /// <returns>The source by identifier.</returns> /// <param name="paramSource">Parameter source.</param> private ArchiveSource GetSourceById (string paramSource) { ArchiveSource source = new ArchiveSource (); Object[] args = { Convert.ToInt64 (paramSource) }; source = (ArchiveSource)appBase.ComponentLoader.InvokeMethod (appBase.MySqlHelper, "SelectSource", args); return source; }