From 264b8b936323d6eff437d0e38ee5f7a1da4144ee Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 13 Mar 2023 12:46:15 -0700 Subject: [PATCH] Ensure Settings Updates are Applied to Experiments --- app/app.go | 2 ++ functionality/filesharing/filesharing_functionality.go | 6 +++--- functionality/filesharing/image_previews.go | 6 +++--- peer/cwtch_peer.go | 1 + peer/storage.go | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/app.go b/app/app.go index 3042c5e..871b32a 100644 --- a/app/app.go +++ b/app/app.go @@ -351,6 +351,8 @@ func (app *application) registerHooks(profile peer.CwtchPeer) { profile.RegisterHook(extensions.ProfileValueExtension{}) profile.RegisterHook(filesharing.Functionality{}) profile.RegisterHook(new(filesharing.ImagePreviewsFunctionality)) + // Ensure that Profiles have the Most Up to Date Settings... + profile.NotifySettingsUpdate(app.settings.ReadGlobalSettings()) } // installProfile takes a profile and if it isn't loaded in the app, installs it and returns true diff --git a/functionality/filesharing/filesharing_functionality.go b/functionality/filesharing/filesharing_functionality.go index 4ec1620..16dd892 100644 --- a/functionality/filesharing/filesharing_functionality.go +++ b/functionality/filesharing/filesharing_functionality.go @@ -68,7 +68,7 @@ func (f Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) { fileSizeLimit, err := strconv.ParseUint(fileSizeLimitValue, 10, bits.UintSize) if err == nil { if manifest.FileSizeInBytes >= fileSizeLimit { - log.Errorf("could not download file, size %v greater than limit %v", manifest.FileSizeInBytes, fileSizeLimitValue) + log.Debugf("could not download file, size %v greater than limit %v", manifest.FileSizeInBytes, fileSizeLimitValue) } else { manifest.Title = manifest.FileName manifest.FileName = downloadFilePath @@ -349,10 +349,10 @@ func (f *Functionality) ReShareFiles(profile peer.CwtchPeer) error { if err == nil && sharedFile.Active { err := f.RestartFileShare(profile, filekey) if err != nil { - log.Errorf("could not reshare file: %v", err) + log.Debugf("could not reshare file: %v", err) } } else { - log.Errorf("could not get fileshare info %v", err) + log.Debugf("could not get fileshare info %v", err) } } } diff --git a/functionality/filesharing/image_previews.go b/functionality/filesharing/image_previews.go index 4b7b911..7deb959 100644 --- a/functionality/filesharing/image_previews.go +++ b/functionality/filesharing/image_previews.go @@ -103,13 +103,13 @@ func (i *ImagePreviewsFunctionality) handleImagePreviews(profile peer.CwtchPeer, // Short-circuit failures // Don't autodownload images if the download path does not exist. if i.downloadFolder == "" { - log.Debugf("download folder %v is not set", i.downloadFolder) + log.Errorf("download folder %v is not set", i.downloadFolder) return } // Don't autodownload images if the download path does not exist. if _, err := os.Stat(i.downloadFolder); os.IsNotExist(err) { - log.Debugf("download folder %v does not exist", i.downloadFolder) + log.Errorf("download folder %v does not exist", i.downloadFolder) return } @@ -127,7 +127,7 @@ func (i *ImagePreviewsFunctionality) handleImagePreviews(profile peer.CwtchPeer, if fm.ShouldAutoDL() { basepath := i.downloadFolder fp, mp := GenerateDownloadPath(basepath, fm.Name, false) - log.Debugf("autodownloading file!") + log.Debugf("autodownloading file! %v %v %v", basepath, fp, i.downloadFolder) ev.Data["Auto"] = constants.True mID, _ := strconv.Atoi(ev.Data["Index"]) profile.UpdateMessageAttribute(conversationID, 0, mID, constants.AttrDownloaded, constants.True) diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index ddc2791..e8dc432 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -193,6 +193,7 @@ func (cp *cwtchPeer) UpdateExperiments(enabled bool, experiments map[string]bool // NotifySettingsUpdate notifies a Cwtch profile of a change in the nature of global experiments. The Cwtch Profile uses // this information to update registered extensions. func (cp *cwtchPeer) NotifySettingsUpdate(settings settings.GlobalSettings) { + log.Debugf("Cwtch Profile Settings Update: %v", settings) cp.extensionLock.Lock() defer cp.extensionLock.Unlock() for _, extension := range cp.extensions { diff --git a/peer/storage.go b/peer/storage.go index 42a5872..197cb16 100644 --- a/peer/storage.go +++ b/peer/storage.go @@ -155,7 +155,7 @@ func CreateEncryptedStore(profileDirectory string, password string) (*CwtchProfi // FromEncryptedDatabase constructs a Cwtch Profile from an existing Encrypted Database func FromEncryptedDatabase(profileDirectory string, password string) (CwtchPeer, error) { - log.Infof("Loading Encrypted Profile: %v", profileDirectory) + log.Debugf("Loading Encrypted Profile: %v", profileDirectory) db, err := openEncryptedDatabase(profileDirectory, password, false) if db == nil || err != nil { return nil, fmt.Errorf("unable to open encrypted database: error: %v", err)