private void Cache_FileAquired(OpVersionedFile file) { // get profile OpProfile prevProfile = GetProfile(file.UserID); OpProfile newProfile = new OpProfile(file); ProfileMap.SafeAdd(file.UserID, newProfile); if (file.UserID == Core.UserID) { LocalProfile = newProfile; } if ((newProfile == LocalProfile) || (prevProfile != null && prevProfile.Loaded)) { LoadProfile(newProfile.UserID); } // update subs if (Network.Established) { List <LocationData> locations = new List <LocationData>(); Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { if (newProfile.UserID == Core.UserID || Trust.IsHigher(newProfile.UserID, project)) { Trust.GetLocsBelow(Core.UserID, project, locations); } } }); Store.PublishDirect(locations, newProfile.UserID, ServiceID, 0, file.SignedHeader); } if (ProfileUpdate != null) { Core.RunInGuiThread(ProfileUpdate, newProfile); } if (Core.NewsWorthy(newProfile.UserID, 0, false)) { Core.MakeNews(ServiceIDs.Profile, "Profile updated by " + Core.GetName(newProfile.UserID), newProfile.UserID, 0, true); } }
void Cache_FileAquired(OpVersionedFile file) { // unload old file OpStorage prevStorage = GetStorage(file.UserID); if (prevStorage != null) { string oldPath = GetFilePath(prevStorage); UnloadHeaderFile(oldPath, prevStorage.File.Header.FileKey); } OpStorage newStorage = new OpStorage(file); StorageMap.SafeAdd(file.UserID, newStorage); LoadHeaderFile(GetFilePath(newStorage), newStorage, false, false); // record changes of higher nodes for auto-integration purposes Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { List <ulong> inheritIDs = Trust.GetAutoInheritIDs(Core.UserID, project); if (Core.UserID == newStorage.UserID || inheritIDs.Contains(newStorage.UserID)) { // doesnt get called on startup because working not initialized before headers are loaded if (Working.ContainsKey(project)) { bool doSave = Working[project].RefreshHigherChanges(newStorage.UserID); if (!Loading && !SavingLocal) { Working[project].AutoIntegrate(doSave); } } } } }); // update subs - this ensures file not propagated lower until we have it (prevents flood to original poster) if (Network.Established) { List <LocationData> locations = new List <LocationData>(); Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { if (newStorage.UserID == Core.UserID || Trust.IsHigher(newStorage.UserID, project)) { Trust.GetLocsBelow(Core.UserID, project, locations); } } }); Store.PublishDirect(locations, newStorage.UserID, ServiceID, FileTypeCache, file.SignedHeader); } if (StorageUpdate != null) { Core.RunInGuiThread(StorageUpdate, newStorage); } if (Core.NewsWorthy(newStorage.UserID, 0, false)) { Core.MakeNews(ServiceIDs.Storage, "File System updated by " + Core.GetName(newStorage.UserID), newStorage.UserID, 0, false); } }
private void Cache_FileAquired(OpVersionedFile file) { OpPlan prevPlan = GetPlan(file.UserID, false); OpPlan newPlan = new OpPlan(file); PlanMap.SafeAdd(newPlan.UserID, newPlan); if (file.UserID == Core.UserID) { LocalPlan = newPlan; } if ((newPlan == LocalPlan) || (prevPlan != null && prevPlan.Loaded)) // if loaded, reload { LoadPlan(newPlan.UserID); } // update subs if (Network.Established) { List <LocationData> locations = new List <LocationData>(); Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { if (newPlan.UserID == Core.UserID || Trust.IsHigher(newPlan.UserID, project)) { Trust.GetLocsBelow(Core.UserID, project, locations); } } }); Store.PublishDirect(locations, newPlan.UserID, ServiceID, DataTypeFile, newPlan.File.SignedHeader); } // see if we need to update our own goal estimates if (newPlan.UserID != Core.UserID && LocalPlan != null) { Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { if (Trust.IsLower(Core.UserID, newPlan.UserID, project)) // updated plan must be lower than us to have an effect { foreach (int ident in LocalPlan.GoalMap.Keys) { if (!newPlan.Loaded) { LoadPlan(newPlan.UserID); } // if updated plan part of the same goal ident, re-estimate our own goals, incorporating update's changes if (newPlan.GoalMap.ContainsKey(ident) || newPlan.ItemMap.ContainsKey(ident)) { foreach (PlanGoal goal in LocalPlan.GoalMap[ident]) { int completed = 0, total = 0; GetEstimate(goal, ref completed, ref total); if (completed != goal.EstCompleted || total != goal.EstTotal) { goal.EstCompleted = completed; goal.EstTotal = total; if (RunSaveLocal == 0) // if countdown not started, start { RunSaveLocal = SaveInterval; } } } } } } } }); } Core.RunInGuiThread(PlanUpdate, newPlan); if (Core.NewsWorthy(newPlan.UserID, 0, false)) { Core.MakeNews(ServiceIDs.Plan, "Plan updated by " + Core.GetName(newPlan.UserID), newPlan.UserID, 0, false); } }