Logging Fixes / InitApp -> InitAppSettings

This commit is contained in:
Sarah Jamie Lewis 2023-02-28 10:00:32 -08:00
parent aceb4adeb1
commit 14962e2428
3 changed files with 15 additions and 4 deletions

View File

@ -35,6 +35,16 @@ type application struct {
settings *GlobalSettingsFile
}
func (app *application) IsFeatureEnabled(experiment string) bool {
settings := app.ReadSettings()
if settings.ExperimentsEnabled {
if status, exists := settings.Experiments[experiment]; exists {
return status
}
}
return false
}
// Application is a full cwtch peer application. It allows management, usage and storage of multiple peers
type Application interface {
LoadProfiles(password string)
@ -56,6 +66,7 @@ type Application interface {
ReadSettings() GlobalSettings
UpdateSettings(settings GlobalSettings)
IsFeatureEnabled(experiment string) bool
ShutdownPeer(string)
Shutdown()
@ -67,7 +78,7 @@ type Application interface {
// LoadProfileFn is the function signature for a function in an app that loads a profile
type LoadProfileFn func(profile peer.CwtchPeer)
func InitApp(appDirectory string) *GlobalSettingsFile {
func LoadAppSettings(appDirectory string) *GlobalSettingsFile {
log.Debugf("NewApp(%v)\n", appDirectory)
os.MkdirAll(path.Join(appDirectory, "profiles"), 0700)

View File

@ -41,7 +41,7 @@ func (pne ProfileValueExtension) OnContactReceiveValue(profile peer.CwtchPeer, c
// OnContactRequestValue for ProfileValueExtension handles returning Public Profile Values
func (pne ProfileValueExtension) OnContactRequestValue(profile peer.CwtchPeer, conversation model.Conversation, eventID string, szp attr.ScopedZonedPath) {
scope, zone, zpath := szp.GetScopeZonePath()
log.Infof("Looking up public | conversation scope/zone %v", szp.ToString())
log.Debugf("Looking up public | conversation scope/zone %v", szp.ToString())
if scope.IsPublic() || scope.IsConversation() {
val, exists := profile.GetScopedZonedAttribute(scope, zone, zpath)

View File

@ -181,7 +181,7 @@ func (om *OverlayMessage) ShouldAutoDL() bool {
func (f *Functionality) VerifyOrResumeDownload(profile peer.CwtchPeer, conversation int, fileKey string) {
if manifestFilePath, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.manifest", fileKey)); exists {
if downloadfilepath, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.path", fileKey)); exists {
log.Infof("resuming %s", fileKey)
log.Debugf("resuming %s", fileKey)
f.DownloadFile(profile, conversation, downloadfilepath, manifestFilePath, fileKey, files.MaxManifestSize*files.DefaultChunkSize)
} else {
log.Errorf("found manifest path but not download path for %s", fileKey)
@ -201,7 +201,7 @@ func (f *Functionality) CheckDownloadStatus(profile peer.CwtchPeer, fileKey stri
event.TempFile: "",
}))
} else {
log.Infof("CheckDownloadStatus found .path but not .complete")
log.Debugf("CheckDownloadStatus found .path but not .complete")
profile.PublishEvent(event.NewEvent(event.FileDownloadProgressUpdate, map[event.Field]string{
event.ProfileOnion: profile.GetOnion(),
event.FileKey: fileKey,