Skip to content
Snippets Groups Projects
Commit 2bb8f811 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] sync: FS sync failed when source and target archives where not the same

parent 2b1cf691
No related branches found
No related tags found
No related merge requests found
......@@ -165,15 +165,18 @@ export class ChunkGetter {
handler.downloader = this.p2PDownloader // If ever the first call does not chains well, we try using P2P
;(handler as any).state = 'WAITING'
i++
} else if (handler.downloader !== this.fsDownloader) {
// Store the file to avoid re-downloading
if (this.localNumber <= 0 && chunk.length === CommonConstants.CONST_BLOCKS_CHUNK) {
await this.writeDAL.confDAL.coreFS.makeTree(this.syncStrategy.getCurrency())
const content = { blocks: chunk.map((b:any) => DBBlock.fromBlockDTO(b)) }
await this.writeDAL.confDAL.coreFS.writeJSON(fileName, content)
}
} else {
logger.warn("Chunk #%s read from filesystem.", i)
let doWrite = handler.downloader !== this.fsDownloader
|| !(await this.writeDAL.confDAL.coreFS.exists(fileName))
if (doWrite) {
// Store the file to avoid re-downloading
if (this.localNumber <= 0 && chunk.length === CommonConstants.CONST_BLOCKS_CHUNK) {
await this.writeDAL.confDAL.coreFS.makeTree(this.syncStrategy.getCurrency())
const content = { blocks: chunk.map((b:any) => DBBlock.fromBlockDTO(b)) }
await this.writeDAL.confDAL.coreFS.writeJSON(fileName, content)
}
}
}
if (chainsWell) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment