1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fix blog updating on proper scanning.

This commit is contained in:
Patrik J. Braun 2023-09-21 22:06:23 +02:00
parent a6bfced5f0
commit f5ed66d0ad
2 changed files with 143 additions and 134 deletions

View File

@ -303,7 +303,8 @@ export class IndexingManager {
})
.getMany();
const metaFilesToSave = [];
const metaFilesToInsert = [];
const MDFilesToUpdate = [];
for (const item of scannedDirectory.metaFile) {
let metaFile: FileDTO = null;
for (let j = 0; j < indexedMetaFiles.length; j++) {
@ -319,18 +320,26 @@ export class IndexingManager {
metaFile = Utils.clone(item);
item.directory = scannedDirectory;
metaFile.directory = {id: currentDirID} as DirectoryBaseDTO;
metaFilesToSave.push(metaFile);
metaFilesToInsert.push(metaFile);
} else if ((item as MDFileDTO).date) {
if ((item as MDFileDTO).date != (metaFile as MDFileDTO).date) {
(metaFile as MDFileDTO).date = (item as MDFileDTO).date;
MDFilesToUpdate.push(metaFile);
}
}
}
const MDFiles = metaFilesToSave.filter(f => !isNaN((f as MDFileDTO).date));
const generalFiles = metaFilesToSave.filter(f => isNaN((f as MDFileDTO).date));
const MDFiles = metaFilesToInsert.filter(f => !isNaN((f as MDFileDTO).date));
const generalFiles = metaFilesToInsert.filter(f => isNaN((f as MDFileDTO).date));
await fileRepository.save(generalFiles, {
chunk: Math.max(Math.ceil(generalFiles.length / 500), 1),
});
await MDfileRepository.save(MDFiles, {
chunk: Math.max(Math.ceil(MDFiles.length / 500), 1),
});
await MDfileRepository.save(MDFilesToUpdate, {
chunk: Math.max(Math.ceil(MDFilesToUpdate.length / 500), 1),
});
await fileRepository.remove(indexedMetaFiles, {
chunk: Math.max(Math.ceil(indexedMetaFiles.length / 500), 1),
});

View File

@ -75,7 +75,7 @@ export class BlogService {
return groupDate;
};
// There is no splits
if (matches.length == 0) {
return [{
text: markdown,