Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-pinner
Commits
484d981e
Commit
484d981e
authored
9 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pin rm fails appropriately for indirect pins
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
96547c99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
pin.go
pin.go
+18
-4
No files found.
pin.go
View file @
484d981e
...
...
@@ -126,18 +126,26 @@ func (p *pinner) Pin(ctx context.Context, node *mdag.Node, recurse bool) error {
func
(
p
*
pinner
)
Unpin
(
ctx
context
.
Context
,
k
key
.
Key
,
recursive
bool
)
error
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
if
p
.
recursePin
.
HasKey
(
k
)
{
reason
,
pinned
,
err
:=
p
.
isPinned
(
k
)
if
err
!=
nil
{
return
err
}
if
!
pinned
{
return
fmt
.
Errorf
(
"%s is not pinned"
,
k
)
}
switch
reason
{
case
"recursive"
:
if
recursive
{
p
.
recursePin
.
RemoveBlock
(
k
)
return
nil
}
else
{
return
fmt
.
Errorf
(
"%s is pinned recursively"
,
k
)
}
}
else
if
p
.
directPin
.
HasKey
(
k
)
{
case
"direct"
:
p
.
directPin
.
RemoveBlock
(
k
)
return
nil
}
else
{
return
fmt
.
Errorf
(
"%s is
not
pinned
"
,
k
)
default
:
return
fmt
.
Errorf
(
"%s is pinned
indirectly under %s"
,
k
,
reason
)
}
}
...
...
@@ -151,6 +159,12 @@ func (p *pinner) isInternalPin(key key.Key) bool {
func
(
p
*
pinner
)
IsPinned
(
k
key
.
Key
)
(
string
,
bool
,
error
)
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
return
p
.
isPinned
(
k
)
}
// isPinned is the implementation of IsPinned that does not lock.
// intended for use by other pinned methods that already take locks
func
(
p
*
pinner
)
isPinned
(
k
key
.
Key
)
(
string
,
bool
,
error
)
{
if
p
.
recursePin
.
HasKey
(
k
)
{
return
"recursive"
,
true
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
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