Skip to content

Commit

Permalink
Fall back to network fetch when storagePath doesn't exist (#4476)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoilie committed Dec 14, 2022
1 parent 31c3ed8 commit ebcfb7f
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 124 deletions.
22 changes: 8 additions & 14 deletions creator-node/src/dbManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ class DBManager {
)?.length
}

static async _getLegacyStoragePathsAndCids(minCid, maxCid, batchSize, dir) {
static async _getLegacyStoragePathRecords(minCid, maxCid, batchSize, dir) {
const dirQuery = `
SELECT "storagePath", "multihash", "skipped" FROM
SELECT "storagePath", "multihash", "dirMultihash", "fileName", "trackBlockchainId", "fileUUID", "skipped" FROM
(SELECT * FROM "Files" AS "Page"
WHERE "multihash" BETWEEN :minCid AND :maxCid AND "type" = 'dir'
ORDER BY "multihash" DESC)
Expand All @@ -445,7 +445,7 @@ class DBManager {
LIMIT :batchSize
`
const nonDirQuery = `
SELECT "storagePath", "multihash", "skipped" FROM
SELECT "storagePath", "multihash", "dirMultihash", "fileName", "trackBlockchainId", "fileUUID", "skipped" FROM
(SELECT * FROM "Files" AS "Page"
WHERE "multihash" BETWEEN :minCid AND :maxCid AND "type" != 'dir'
ORDER BY "multihash" DESC)
Expand All @@ -463,26 +463,20 @@ class DBManager {
fileRecords
)}`
)
return fileRecords.map((result) => {
return {
storagePath: result.storagePath,
cid: result.multihash,
skipped: result.skipped
}
})
return fileRecords
}

static async getNonDirLegacyStoragePathsAndCids(minCid, maxCid, batchSize) {
return DBManager._getLegacyStoragePathsAndCids(
static async getNonDirLegacyStoragePathRecords(minCid, maxCid, batchSize) {
return DBManager._getLegacyStoragePathRecords(
minCid,
maxCid,
batchSize,
false
)
}

static async getDirLegacyStoragePathsAndCids(minCid, maxCid, batchSize) {
return DBManager._getLegacyStoragePathsAndCids(
static async getDirLegacyStoragePathRecords(minCid, maxCid, batchSize) {
return DBManager._getLegacyStoragePathRecords(
minCid,
maxCid,
batchSize,
Expand Down

0 comments on commit ebcfb7f

Please sign in to comment.