Skip to content

Commit d3a6524

Browse files
hacdiasSgtPookilidel
authored
feat: track remote pins in progress (#1919)
Co-authored-by: Russell Dempsey <[email protected]> Co-authored-by: Marcin Rataj <[email protected]>
1 parent b27f3be commit d3a6524

File tree

167 files changed

+2187
-1071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+2187
-1071
lines changed

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"internal-nav-helper": "^3.1.0",
6161
"intl-messageformat": "^9.11.3",
6262
"ip": "^1.1.5",
63-
"ipfs-css": "^1.3.0",
63+
"ipfs-css": "^1.4.0",
6464
"ipfs-geoip": "^8.0.0",
6565
"ipfs-http-client": "49.0.2",
6666
"ipfs-provider": "^2.1.0",

public/locales/en/files.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,16 @@
108108
"checkboxLabel": "View more options for {name}",
109109
"pinned": "Pinned",
110110
"pinnedRemotely": "Pinned remotely",
111+
"pinningRemotely": "Pinning remotely",
112+
"pinningCompleted": "Pinning completed",
113+
"pinningFailed": "Pinning failed",
114+
"clickToDismiss": "Click to dismiss",
115+
"clickToCancel": "Click to cancel",
111116
"blocks": "Blocks",
112117
"allBlocks": "All blocks",
113118
"allBlocksDescription": "Total size of blocks on your entire IPFS node; this includes everything in Files, plus all locally pinned items and any temporary cached data",
114119
"filesDescription": "Total size of data in the current directory (if a subdirectory, the size of all data in Files is also displayed)",
120+
"pinningQueue": "Pinning queue",
115121
"more": "More",
116122
"files": "Files",
117123
"cidNotFileNorDir": "The current link isn't a file, nor a directory. Try to <1>inspect</1> it instead.",
@@ -125,5 +131,7 @@
125131
"linkCopied": "Link copied!",
126132
"sharingPrompt": "Copy the link below and share it with others. The IPNS address will resolve as long as your node remains available on the network once a day to refresh the IPNS record.",
127133
"pleaseWait": "Please wait while the initial 20 copies of the updated IPNS record are stored with the help of DHT peers…"
128-
}
134+
},
135+
"noPinsInProgress": "All done, no remote pins in progress.",
136+
"remotePinningInProgress": "Remote pinning in progress:"
129137
}

src/bundles/files/actions.js

+2-24
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,6 @@ const getRawPins = async function * (ipfs) {
134134
*/
135135
const getPinCIDs = (ipfs) => map(getRawPins(ipfs), (pin) => pin.cid)
136136

137-
/**
138-
* @param {IPFSService} ipfs
139-
* @returns {AsyncIterable<FileStat>}
140-
*/
141-
const getPins = async function * (ipfs) {
142-
for await (const cid of getPinCIDs(ipfs)) {
143-
const info = await stat(ipfs, cid)
144-
yield fileFromStats({ ...info, pinned: true }, '/pins')
145-
}
146-
}
147-
148137
/**
149138
* @typedef {import('./protocol').Message} Message
150139
* @typedef {import('./protocol').Model} Model
@@ -201,22 +190,11 @@ const actions = () => ({
201190
* @param {Info} info
202191
* @returns {function(Context): *}
203192
*/
204-
doFetch: ({ path, realPath, isMfs, isPins, isRoot }) => perform(ACTIONS.FETCH, async (ipfs, { store }) => {
205-
if (isRoot && !isMfs && !isPins) {
193+
doFetch: ({ path, realPath, isMfs, isRoot }) => perform(ACTIONS.FETCH, async (ipfs, { store }) => {
194+
if (isRoot && !isMfs) {
206195
throw new Error('not supposed to be here')
207196
}
208197

209-
if (isRoot && isPins) {
210-
const pins = await all(getPins(ipfs)) // FIX: pins path
211-
212-
return {
213-
path: '/pins',
214-
fetched: Date.now(),
215-
type: 'directory',
216-
content: pins
217-
}
218-
}
219-
220198
const resolvedPath = realPath.startsWith('/ipns')
221199
? await last(ipfs.name.resolve(realPath))
222200
: realPath

src/bundles/files/index.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,15 @@ const createFilesBundle = () => {
5353
const result = task.status === 'Exit' && task.result.ok
5454
? task.result.value
5555
: null
56-
const { pageContent, pins } = result
56+
const { pageContent } = result
5757
? {
58-
pageContent: result,
59-
pins: result.type === 'directory' && result.path === '/pins'
60-
? result.content.map($ => $.cid.toString())
61-
: state.pins
58+
pageContent: result
6259
}
6360
: state
6461

6562
return {
6663
...updateJob(state, task, type),
67-
pageContent,
68-
pins
64+
pageContent
6965
}
7066
}
7167
case ACTIONS.DISMISS_ERRORS: {

src/bundles/files/utils.js

-9
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ export const sortFiles = (files, sorting) => {
189189
* @property {string} path
190190
* @property {string} realPath
191191
* @property {boolean} isMfs
192-
* @property {boolean} isPins
193192
* @property {boolean} isRoot
194193
*
195194
* @param {string} path
@@ -201,7 +200,6 @@ export const infoFromPath = (path, uriDecode = true) => {
201200
path,
202201
realPath: '',
203202
isMfs: false,
204-
isPins: false,
205203
isRoot: false
206204
}
207205

@@ -219,13 +217,6 @@ export const infoFromPath = (path, uriDecode = true) => {
219217
} else if (info.path.startsWith('/files')) {
220218
check('/files')
221219
info.isMfs = true
222-
} else if (info.path.startsWith('/pins')) {
223-
check('/pins')
224-
info.isPins = true
225-
226-
if (info.realPath !== '/') {
227-
info.realPath = `/ipfs${info.realPath}`
228-
}
229220
} else {
230221
return
231222
}

0 commit comments

Comments
 (0)