forked from Silverfish/proton-bridge
GODT-1158: adding cache on disk signals
This commit is contained in:
@ -29,15 +29,44 @@ import (
|
||||
)
|
||||
|
||||
func (f *FrontendQt) setIsDiskCacheEnabled() {
|
||||
//TODO
|
||||
f.qml.SetIsDiskCacheEnabled(f.settings.GetBool(settings.CacheEnabledKey))
|
||||
}
|
||||
|
||||
func (f *FrontendQt) setDiskCachePath() {
|
||||
//TODO
|
||||
f.qml.SetDiskCachePath(f.settings.Get(settings.CacheLocationKey))
|
||||
}
|
||||
|
||||
func (f *FrontendQt) changeLocalCache(enableDiskCache bool, diskCachePath string) {
|
||||
//TODO
|
||||
defer f.qml.ChangeLocalCacheFinished()
|
||||
defer f.setIsDiskCacheEnabled()
|
||||
defer f.setDiskCachePath()
|
||||
|
||||
if enableDiskCache != f.settings.GetBool(settings.CacheEnabledKey) {
|
||||
if enableDiskCache {
|
||||
if err := f.bridge.EnableCache(); err != nil {
|
||||
f.log.WithError(err).Error("Cannot enable disk cache")
|
||||
}
|
||||
} else {
|
||||
if err := f.bridge.DisableCache(); err != nil {
|
||||
f.log.WithError(err).Error("Cannot disable disk cache")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If disk cache not enabled, or path not changed then no need to change location
|
||||
if !enableDiskCache || diskCachePath == f.settings.Get(settings.CacheLocationKey) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := f.bridge.MigrateCache(f.settings.Get(settings.CacheLocationKey), diskCachePath); err != nil {
|
||||
f.log.WithError(err).Error("The local cache location could not be changed.")
|
||||
f.qml.CacheCantMove()
|
||||
return
|
||||
}
|
||||
|
||||
f.settings.Set(settings.CacheLocationKey, diskCachePath)
|
||||
f.qml.CacheLocationChangeSuccess()
|
||||
f.restart()
|
||||
}
|
||||
|
||||
func (f *FrontendQt) setIsAutostartOn() {
|
||||
|
||||
@ -164,7 +164,7 @@ func (q *QMLBackend) setup(f *FrontendQt) {
|
||||
|
||||
f.setIsDiskCacheEnabled()
|
||||
f.setDiskCachePath()
|
||||
q.ConnectChangeLocalCache(f.changeLocalCache)
|
||||
q.ConnectChangeLocalCache(func(e bool, d string) { go f.changeLocalCache(e, d) })
|
||||
|
||||
f.setIsAutomaticUpdateOn()
|
||||
q.ConnectToggleAutomaticUpdate(func(m bool) { go f.toggleAutomaticUpdate(m) })
|
||||
|
||||
Reference in New Issue
Block a user