Merge pull request #3125 from dpalou/MOBILE-3799

MOBILE-3799 filepool: Fix regression when checking outdated files
main
Pau Ferrer Ocaña 2022-02-17 11:46:33 +01:00 committed by GitHub
commit 37bde23418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -383,7 +383,7 @@ export class CoreFilepoolProvider {
if (!alreadyFixed) { if (!alreadyFixed) {
// Fix the URL and use the fixed data. // Fix the URL and use the fixed data.
const file = await this.fixPluginfileURL(siteId, fileUrl); const file = await this.fixPluginfileURL(siteId, fileUrl, timemodified);
fileUrl = CoreFileHelper.getFileUrl(file); fileUrl = CoreFileHelper.getFileUrl(file);
timemodified = file.timemodified ?? timemodified; timemodified = file.timemodified ?? timemodified;
@ -1030,11 +1030,11 @@ export class CoreFilepoolProvider {
throw new CoreError('File system cannot be used.'); throw new CoreError('File system cannot be used.');
} }
const file = await this.fixPluginfileURL(siteId, fileUrl); const file = await this.fixPluginfileURL(siteId, fileUrl, timemodified);
fileUrl = CoreFileHelper.getFileUrl(file); fileUrl = CoreFileHelper.getFileUrl(file);
options = Object.assign({}, options); // Create a copy to prevent modifying the original object. options = Object.assign({}, options); // Create a copy to prevent modifying the original object.
options.timemodified = file.timemodified ?? timemodified ?? 0; options.timemodified = file.timemodified ?? timemodified;
options.revision = revision ?? this.getRevisionFromUrl(fileUrl); options.revision = revision ?? this.getRevisionFromUrl(fileUrl);
const fileId = this.getFileIdByUrl(fileUrl); const fileId = this.getFileIdByUrl(fileUrl);
@ -2340,10 +2340,12 @@ export class CoreFilepoolProvider {
* @param timemodified The time this file was modified. * @param timemodified The time this file was modified.
* @param Whether the file is outdated. * @param Whether the file is outdated.
*/ */
protected isFileOutdated(entry: CoreFilepoolFileEntry, revision?: number, timemodified?: number): boolean { protected isFileOutdated(entry: CoreFilepoolFileEntry, revision = 0, timemodified = 0): boolean {
return !!entry.stale || // Don't allow undefined values, convert them to 0.
(revision !== undefined && (entry.revision === undefined || revision > entry.revision)) || const entryTimemodified = entry.timemodified ?? 0;
(timemodified !== undefined && (entry.timemodified === undefined || timemodified > entry.timemodified)); const entryRevision = entry.revision ?? 0;
return !!entry.stale || revision > entryRevision || timemodified > entryTimemodified;
} }
/** /**
@ -2565,8 +2567,8 @@ export class CoreFilepoolProvider {
const fileId = item.fileId; const fileId = item.fileId;
const fileUrl = item.url; const fileUrl = item.url;
const options = { const options = {
revision: item.revision ?? undefined, revision: item.revision ?? 0,
timemodified: item.timemodified ?? undefined, timemodified: item.timemodified ?? 0,
isexternalfile: item.isexternalfile ?? undefined, isexternalfile: item.isexternalfile ?? undefined,
repositorytype: item.repositorytype ?? undefined, repositorytype: item.repositorytype ?? undefined,
}; };