Logging Fixes / InitApp -> InitAppSettings
This commit is contained in:
parent
aceb4adeb1
commit
14962e2428
13
app/app.go
13
app/app.go
|
@ -35,6 +35,16 @@ type application struct {
|
||||||
settings *GlobalSettingsFile
|
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
|
// Application is a full cwtch peer application. It allows management, usage and storage of multiple peers
|
||||||
type Application interface {
|
type Application interface {
|
||||||
LoadProfiles(password string)
|
LoadProfiles(password string)
|
||||||
|
@ -56,6 +66,7 @@ type Application interface {
|
||||||
|
|
||||||
ReadSettings() GlobalSettings
|
ReadSettings() GlobalSettings
|
||||||
UpdateSettings(settings GlobalSettings)
|
UpdateSettings(settings GlobalSettings)
|
||||||
|
IsFeatureEnabled(experiment string) bool
|
||||||
|
|
||||||
ShutdownPeer(string)
|
ShutdownPeer(string)
|
||||||
Shutdown()
|
Shutdown()
|
||||||
|
@ -67,7 +78,7 @@ type Application interface {
|
||||||
// LoadProfileFn is the function signature for a function in an app that loads a profile
|
// LoadProfileFn is the function signature for a function in an app that loads a profile
|
||||||
type LoadProfileFn func(profile peer.CwtchPeer)
|
type LoadProfileFn func(profile peer.CwtchPeer)
|
||||||
|
|
||||||
func InitApp(appDirectory string) *GlobalSettingsFile {
|
func LoadAppSettings(appDirectory string) *GlobalSettingsFile {
|
||||||
log.Debugf("NewApp(%v)\n", appDirectory)
|
log.Debugf("NewApp(%v)\n", appDirectory)
|
||||||
os.MkdirAll(path.Join(appDirectory, "profiles"), 0700)
|
os.MkdirAll(path.Join(appDirectory, "profiles"), 0700)
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (pne ProfileValueExtension) OnContactReceiveValue(profile peer.CwtchPeer, c
|
||||||
// OnContactRequestValue for ProfileValueExtension handles returning Public Profile Values
|
// OnContactRequestValue for ProfileValueExtension handles returning Public Profile Values
|
||||||
func (pne ProfileValueExtension) OnContactRequestValue(profile peer.CwtchPeer, conversation model.Conversation, eventID string, szp attr.ScopedZonedPath) {
|
func (pne ProfileValueExtension) OnContactRequestValue(profile peer.CwtchPeer, conversation model.Conversation, eventID string, szp attr.ScopedZonedPath) {
|
||||||
scope, zone, zpath := szp.GetScopeZonePath()
|
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() {
|
if scope.IsPublic() || scope.IsConversation() {
|
||||||
val, exists := profile.GetScopedZonedAttribute(scope, zone, zpath)
|
val, exists := profile.GetScopedZonedAttribute(scope, zone, zpath)
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ func (om *OverlayMessage) ShouldAutoDL() bool {
|
||||||
func (f *Functionality) VerifyOrResumeDownload(profile peer.CwtchPeer, conversation int, fileKey string) {
|
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 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 {
|
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)
|
f.DownloadFile(profile, conversation, downloadfilepath, manifestFilePath, fileKey, files.MaxManifestSize*files.DefaultChunkSize)
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("found manifest path but not download path for %s", fileKey)
|
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: "",
|
event.TempFile: "",
|
||||||
}))
|
}))
|
||||||
} else {
|
} 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{
|
profile.PublishEvent(event.NewEvent(event.FileDownloadProgressUpdate, map[event.Field]string{
|
||||||
event.ProfileOnion: profile.GetOnion(),
|
event.ProfileOnion: profile.GetOnion(),
|
||||||
event.FileKey: fileKey,
|
event.FileKey: fileKey,
|
||||||
|
|
Loading…
Reference in New Issue