Skip to content

Commit

Permalink
fixes #141, rmdir updates feed with magicword
Browse files Browse the repository at this point in the history
  • Loading branch information
asabya committed Nov 10, 2021
1 parent cf3e6c6 commit 121f534
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion pkg/dir/dir_present.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (
// IsDirectoryPresent this function check if a given directory is present inside the pod.
func (d *Directory) IsDirectoryPresent(directoryNameWithPath string) bool {
topic := utils.HashString(directoryNameWithPath)
_, _, err := d.fd.GetFeedData(topic, d.userAddress)
_, metaBytes, err := d.fd.GetFeedData(topic, d.userAddress)
if string(metaBytes) == utils.DeletedFeedMagicWord {
return false
}
return err == nil
}
6 changes: 3 additions & 3 deletions pkg/dir/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func (d *Directory) MkDir(dirToCreateWithPath string) error {
}

// upload the metadata as blob
previousAddr, previousData, err := d.fd.GetFeedData(topic, d.userAddress)
if err == nil && previousAddr != nil && previousData != nil {
_, err = d.fd.UpdateFeed(topic, d.userAddress, previousData)
previousAddr, _, err := d.fd.GetFeedData(topic, d.userAddress)
if err == nil && previousAddr != nil {
_, err = d.fd.UpdateFeed(topic, d.userAddress, data)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dir/rmdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (d *Directory) RmDir(directoryNameWithPath string) error {

// remove the feed and clear the data structure
topic := utils.HashString(totalPath)
err := d.fd.DeleteFeed(topic, d.userAddress)
_, err := d.fd.UpdateFeed(topic, d.userAddress, []byte(utils.DeletedFeedMagicWord))
if err != nil {
return err
}
Expand Down

0 comments on commit 121f534

Please sign in to comment.