Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ipfs-images-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ipfs-images
ipfs-images-components
Commits
075297d3
Commit
075297d3
authored
May 10, 2017
by
Vladislav Bashkirev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Pin#check method
Method checks if all attachments found in Redis are pinned.
parent
6d1680bf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
DOCS.md
DOCS.md
+9
-0
README.md
README.md
+9
-0
pin.js
components/pin.js
+22
-0
No files found.
DOCS.md
View file @
075297d3
...
@@ -129,6 +129,7 @@ to pin attachments.
...
@@ -129,6 +129,7 @@ to pin attachments.
*
[
Pin
](
#Pin
)
*
[
Pin
](
#Pin
)
*
[
new Pin()
](
#new_Pin_new
)
*
[
new Pin()
](
#new_Pin_new
)
*
[
.all()
](
#Pin+all
)
⇒
<code>
Promise
</code>
*
[
.all()
](
#Pin+all
)
⇒
<code>
Promise
</code>
*
[
.check()
](
#Pin+check
)
⇒
<code>
Promise
</code>
<a
name=
"new_Pin_new"
></a>
<a
name=
"new_Pin_new"
></a>
...
@@ -142,6 +143,14 @@ Pins attachments to local storage for which there are records in Redis.
...
@@ -142,6 +143,14 @@ Pins attachments to local storage for which there are records in Redis.
**Kind**
: instance method of
[
<code>Pin</code>
](
#Pin
)
**Kind**
: instance method of
[
<code>Pin</code>
](
#Pin
)
**Returns**
:
<code>
Promise
</code>
- Number of pinned attachments.
**Returns**
:
<code>
Promise
</code>
- Number of pinned attachments.
<a
name=
"Pin+check"
></a>
### pin.check() ⇒ <code>Promise</code>
Checks if IPFS objects for hashes found in Redis are stored locally.
**Kind**
: instance method of
[
<code>Pin</code>
](
#Pin
)
**Returns**
:
<code>
Promise
</code>
- Resolves with array of unpinned hashes or rejects with
error. If array is empty, all hashes are pinned.
<a
name=
"Cleaner"
></a>
<a
name=
"Cleaner"
></a>
## Cleaner
## Cleaner
...
...
README.md
View file @
075297d3
...
@@ -148,6 +148,7 @@ to pin attachments.
...
@@ -148,6 +148,7 @@ to pin attachments.
*
[
Pin
](
#Pin
)
*
[
Pin
](
#Pin
)
*
[
new Pin()
](
#new_Pin_new
)
*
[
new Pin()
](
#new_Pin_new
)
*
[
.all()
](
#Pin+all
)
⇒
<code>
Promise
</code>
*
[
.all()
](
#Pin+all
)
⇒
<code>
Promise
</code>
*
[
.check()
](
#Pin+check
)
⇒
<code>
Promise
</code>
<a
name=
"new_Pin_new"
></a>
<a
name=
"new_Pin_new"
></a>
...
@@ -161,6 +162,14 @@ Pins attachments to local storage for which there are records in Redis.
...
@@ -161,6 +162,14 @@ Pins attachments to local storage for which there are records in Redis.
**Kind**
: instance method of
[
<code>Pin</code>
](
#Pin
)
**Kind**
: instance method of
[
<code>Pin</code>
](
#Pin
)
**Returns**
:
<code>
Promise
</code>
- Number of pinned attachments.
**Returns**
:
<code>
Promise
</code>
- Number of pinned attachments.
<a
name=
"Pin+check"
></a>
### pin.check() ⇒ <code>Promise</code>
Checks if IPFS objects for hashes found in Redis are stored locally.
**Kind**
: instance method of
[
<code>Pin</code>
](
#Pin
)
**Returns**
:
<code>
Promise
</code>
- Resolves with array of unpinned hashes or rejects with
error. If array is empty, all hashes are pinned.
<a
name=
"Cleaner"
></a>
<a
name=
"Cleaner"
></a>
## Cleaner
## Cleaner
...
...
components/pin.js
View file @
075297d3
...
@@ -47,6 +47,28 @@ class Pin {
...
@@ -47,6 +47,28 @@ class Pin {
throw
error
;
throw
error
;
});
});
}
}
/**
* Checks if IPFS objects for hashes found in Redis are stored locally.
* @return {Promise} Resolves with array of unpinned hashes or rejects with
* error. If array is empty, all hashes are pinned.
*/
check
()
{
logging
.
info
(
'Checking if all attachments are locally stored'
);
return
Promise
.
join
(
this
.
ipfs
.
refs
.
local
(),
redis
.
keysAsync
(
this
.
prefix
+
'*'
)
).
spread
((
refs
,
keys
)
=>
{
let
hashes
=
keys
.
map
((
key
)
=>
key
.
split
(
'_'
)[
1
]);
logging
.
info
(
`Found
${
hashes
.
length
}
attachments
and
${
refs
.
length
}
local objects`
);
return
hashes
.
filter
(
refs
.
includes
);
}).
catch
((
error
)
=>
{
throw
error
;
});
}
}
}
module
.
exports
=
Pin
;
module
.
exports
=
Pin
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment