private void AddFile(CFile file) { if (!m_Contains(file.FileHash)) { CElement Element=new CElement(); Element.File=file; Element.Statistics=new CFileStatistics(); m_FileList.Add(Element); if (((file.FileStatus==Protocol.FileState.Ready)||(Element.File.FileStatus==Protocol.FileState.Completing))&&(!file.Completed)) { Element.SourcesList=new CSourcesList(Element); Element.Comments=new CedonkeyComments(Element); } if (!file.Completed) CKernel.NewFile(Element); else CKernel.NewSharedFile(Element); } else { CLog.Log(Constants.Log.Notify, "FIL_DUP",CKernel.HashToString(file.FileHash)); file=null; } }
public void LoadIncompletedFiles() { foreach (string folder in CKernel.Preferences.GetStringArray("TempFolders")) { try { string [] files=Directory.GetFiles(folder); foreach (string strfile in files) { if (Path.GetExtension(strfile).Equals(".part")) { CFile file=new CFile(Path.GetDirectoryName(strfile),Path.GetFileName(strfile)); if (file.FileHash!=null) AddFile(file); //file loaded properly } } } catch (IOException e) { // any temp directory don't exist Debug.Write( e.ToString() ); } } }
public void AddFile(string fichero, byte[] Hash, ArrayList HashSet) { FileInfo info= new FileInfo(fichero); CFile Fichero=new CFile(Hash,File.GetLastWriteTime(fichero).ToUniversalTime(),Path.GetDirectoryName(fichero),Path.GetFileName(fichero),(uint)info.Length,Constants.Priority.Normal,0, HashSet,"",0); AddFile(Fichero); SaveList(""); }
public void EmptyFileToSharedFile(CFile file) { CElement Element=this[file.FileHash]; if (Element!=null) CKernel.NewSharedFile(Element); //TODO publish the file on the conected server if (CKernel.ServersList.ActiveServer!=null) CKernel.ServersList.ActiveServer.PublishSharedFile(Element); }
public void AddFile(string name, uint size, byte[] Hash, stDatosFuente[] sources) { CElement Element; if (this.m_Contains(Hash)) { CLog.Log(Constants.Log.Notify,"FIL_DUP",name); Element=(CElement)this[Hash]; } else { CFile file=new CFile(Hash,name,size); Element=new CElement(); Element.File=file; Element.Statistics=new CFileStatistics(); m_FileList.Add(Element); CKernel.NewFile(Element); CLog.Log(Constants.Log.Notify,"FIL_ADDED",name); } if ((Element.SourcesList==null)&&((Element.File.FileStatus==Protocol.FileState.Ready)||(Element.File.FileStatus==Protocol.FileState.Completing))) { CSourcesList sourcesList=new CSourcesList(Element); Element.SourcesList=sourcesList; if (CKernel.ServersList.ActiveServer!=null) CKernel.ServersList.ActiveServer.RequestSources(Element.File.FileHash); } if ((Element.SourcesList!=null)&& ((Element.File.FileStatus==Protocol.FileState.Ready)||(Element.File.FileStatus==Protocol.FileState.Completing))&& (sources!=null)) CKernel.ClientsList.AddClientsToFile(sources,Hash); }