public void Dispose() { //crit - public shared directory can be deleted here, except for our local public header ProcessFiles.Dispose(); OpenFiles.Dispose(); Core.SecondTimerEvent -= Core_SecondTimer; // file Network.RudpControl.SessionUpdate -= new SessionUpdateHandler(Session_Update); Network.RudpControl.SessionData[ServiceID, DataTypeShare] -= new SessionDataHandler(Session_Data); Core.Transfers.FileSearch[ServiceID, DataTypeShare] -= new FileSearchHandler(Transfers_FileSearch); Core.Transfers.FileRequest[ServiceID, DataTypeShare] -= new FileRequestHandler(Transfers_FileRequest); TempLocation.Dispose(); }
public void Dispose() { if (Disposing != null) { Disposing(); } HashFiles.Dispose(); CopyFiles.Dispose(); // lock down working List <LockError> errors = new List <LockError>(); foreach (WorkingStorage working in Working.Values) { working.LockAll(errors); if (working.Modified) { working.SaveWorking(); } } Working.Clear(); // delete completely folders made for other user's storages Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { string path = Core.User.RootPath + Path.DirectorySeparatorChar + Trust.GetProjectName(project) + " Storage"; string local = Core.GetName(Core.UserID); if (Directory.Exists(path)) { foreach (string dir in Directory.GetDirectories(path)) { if (Path.GetFileName(dir) != local) { try { Directory.Delete(dir, true); } catch { errors.Add(new LockError(dir, "", false, LockErrorType.Blocked)); } } } } } }); // security warning: could not secure these files if (errors.Count > 0) { string message = "Security Warning: Not able to delete these files, please do it manually\n"; foreach (LockError error in errors) { if (error.Type == LockErrorType.Blocked) { message += error.Path; } } Core.UserMessage(message); } // kill events Core.SecondTimerEvent -= Core_SecondTimer; Core.MinuteTimerEvent -= Core_MinuteTimer; Network.CoreStatusChange -= new StatusChange(Network_StatusChange); Cache.FileAquired -= new FileAquiredHandler(Cache_FileAquired); Cache.FileRemoved -= new FileRemovedHandler(Cache_FileRemoved); Cache.Dispose(); Core.Transfers.FileSearch[ServiceID, FileTypeData] -= new FileSearchHandler(Transfers_DataFileSearch); Core.Transfers.FileRequest[ServiceID, FileTypeData] -= new FileRequestHandler(Transfers_DataFileRequest); Core.Trust.LinkUpdate -= new LinkUpdateHandler(Trust_Update); }