Potential fox to file reload race condition
parent
34af1b1bb6
commit
221e9e859c
|
@ -29,13 +29,19 @@ export class EventedSpacePrimitives implements SpacePrimitives {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchFileList(): Promise<FileMeta[]> {
|
async fetchFileList(): Promise<FileMeta[]> {
|
||||||
const newFileList = await this.wrapped.fetchFileList();
|
|
||||||
if (this.alreadyFetching) {
|
if (this.alreadyFetching) {
|
||||||
// Avoid race conditions, let's just skip this in terms of event triggering: that's ok
|
// Some other operation (read, write, list, meta) is already going on
|
||||||
return newFileList;
|
// this will likely trigger events, so let's not worry about any of that and avoid race condition and inconsistent data.
|
||||||
|
console.info(
|
||||||
|
"alreadyFetching is on, skipping even triggering for fetchFileList.",
|
||||||
|
);
|
||||||
|
return this.wrapped.fetchFileList();
|
||||||
}
|
}
|
||||||
|
// Fetching mutex
|
||||||
|
this.alreadyFetching = true;
|
||||||
|
// Fetch the list
|
||||||
|
const newFileList = await this.wrapped.fetchFileList();
|
||||||
try {
|
try {
|
||||||
this.alreadyFetching = true;
|
|
||||||
const deletedFiles = new Set<string>(Object.keys(this.spaceSnapshot));
|
const deletedFiles = new Set<string>(Object.keys(this.spaceSnapshot));
|
||||||
for (const meta of newFileList) {
|
for (const meta of newFileList) {
|
||||||
const oldHash = this.spaceSnapshot[meta.name];
|
const oldHash = this.spaceSnapshot[meta.name];
|
||||||
|
|
|
@ -603,7 +603,6 @@ export class Client {
|
||||||
if (
|
if (
|
||||||
this.space.watchInterval && `${this.currentPage}.md` === path
|
this.space.watchInterval && `${this.currentPage}.md` === path
|
||||||
) {
|
) {
|
||||||
console.trace();
|
|
||||||
console.log(
|
console.log(
|
||||||
"Page changed elsewhere, reloading. Old hash",
|
"Page changed elsewhere, reloading. Old hash",
|
||||||
oldHash,
|
oldHash,
|
||||||
|
|
Loading…
Reference in New Issue