Skip to content

Commit 0e0a426

Browse files
committed
fix(storage): Add checkStorage method to freeStorage regularly
Signed-off-by: Marcel Klehr <[email protected]>
1 parent a207471 commit 0e0a426

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/lib/browser/BrowserController.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class AlarmManager {
2222
this.ctl = ctl
2323
}
2424

25+
async checkStorage() {
26+
await freeStorageIfNecessary()
27+
}
28+
2529
async checkSync() {
2630
const accounts = await BrowserAccountStorage.getAllAccounts()
2731
for (let accountId of accounts) {
@@ -105,6 +109,7 @@ export default class BrowserController {
105109

106110
// Set up the alarms
107111

112+
browser.alarms.create('checkStorage', { periodInMinutes: 15 })
108113
browser.alarms.create('checkSync', { periodInMinutes: 1 })
109114
browser.alarms.onAlarm.addListener(async alarm => {
110115
await this.alarms[alarm.name]()
@@ -129,7 +134,6 @@ export default class BrowserController {
129134
},
130135
[]
131136
)
132-
freeStorageIfNecessary()
133137

134138
// do some cleaning if this is a new version
135139

src/lib/native/NativeController.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class AlarmManager {
1515
this.ctl = ctl
1616
this.backgroundSyncEnabled = true
1717
setInterval(() => this.checkSync(), 25 * 1000)
18+
setInterval(() => this.checkStorage(), 30 * 1000)
1819

1920
Network.addListener('networkStatusChange', status => {
2021
if (status.connected) {
@@ -25,6 +26,10 @@ class AlarmManager {
2526
})
2627
}
2728

29+
async checkStorage() {
30+
await freeStorageIfNecessary()
31+
}
32+
2833
async checkSync() {
2934
if (!this.backgroundSyncEnabled) {
3035
return
@@ -93,7 +98,6 @@ export default class NativeController {
9398
},
9499
[]
95100
)
96-
freeStorageIfNecessary()
97101

98102
// lock accounts when locking is enabled
99103

0 commit comments

Comments
 (0)