Skip to content

Commit 244d6da

Browse files
committed
HOUSEKEEPING: Minor fixes all over
1 parent da7633b commit 244d6da

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

glean/src/core/dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const enum Commands {
4747
// The dispatcher will clear the queue and go into the Shutdown state.
4848
Shutdown,
4949
// Exactly like a normal Task, but spawned for tests.
50-
TestTask = "TestTask",
50+
TestTask,
5151
}
5252

5353
// A task the dispatcher knows how to execute.

glean/src/core/glean.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,7 @@ class Glean {
218218
Context.pingsDatabase = new PingsDatabase(Glean.platform.Storage);
219219
Context.errorManager = new ErrorManager();
220220

221-
Glean.instance._pingUploader = new PingUploader(
222-
correctConfig,
223-
Glean.platform,
224-
Context.pingsDatabase
225-
);
221+
Glean.instance._pingUploader = new PingUploader(correctConfig, Glean.platform);
226222

227223
Context.pingsDatabase.attachObserver(Glean.pingUploader);
228224

@@ -286,6 +282,10 @@ class Glean {
286282
}
287283
}
288284

285+
// We only scan the pendings pings **after** dealing with the upload state.
286+
// If upload is disabled, we delete all pending pings files
287+
// and we need to do that **before** scanning the pending pings
288+
// to ensure we don't enqueue pings before their files are deleted.
289289
await Context.pingsDatabase.scanPendingPings();
290290
});
291291
}

glean/src/core/upload/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,15 @@ class PingUploader implements PingsDatabaseObserver {
9090
constructor(
9191
config: Configuration,
9292
platform: Platform,
93-
private readonly pingsDatabase: PingsDatabase,
94-
private readonly policy = new Policy
93+
private readonly pingsDatabase = Context.pingsDatabase,
94+
private readonly policy = new Policy()
9595
) {
9696
this.processing = [];
9797
// Initialize the ping uploader with either the platform defaults or a custom
9898
// provided uploader from the configuration object.
9999
this.uploader = config.httpClient ? config.httpClient : platform.uploader;
100100
this.platformInfo = platform.info;
101101
this.serverEndpoint = config.serverEndpoint;
102-
this.pingsDatabase = pingsDatabase;
103102

104103
// Initialize the dispatcher immediatelly.
105104
this.dispatcher = createAndInitializeDispatcher();
@@ -124,6 +123,7 @@ class PingUploader implements PingsDatabaseObserver {
124123

125124
// If the ping is a deletion-request ping, we want to enqueue it as a persistent task,
126125
// so that clearing the queue does not clear it.
126+
//
127127
// eslint-disable-next-line @typescript-eslint/unbound-method
128128
const launchFn = isDeletionRequest(ping) ? this.dispatcher.launchPersistent : this.dispatcher.launch;
129129

@@ -298,7 +298,6 @@ class PingUploader implements PingsDatabaseObserver {
298298
if (status && status >= 200 && status < 300) {
299299
log(LOG_TAG, `Ping ${identifier} succesfully sent ${status}.`, LoggingLevel.Info);
300300
await this.pingsDatabase.deletePing(identifier);
301-
this.processing;
302301
return false;
303302
}
304303

0 commit comments

Comments
 (0)