mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-01-10 12:24:20 +01:00
delete function now checks for previous versions and deletes them as well
This commit is contained in:
parent
aecf89339c
commit
ce1700c36c
@ -274,6 +274,21 @@ BoardsAPI.prototype.delete = function (opts, done) {
|
||||
for (var item in list) {
|
||||
if (list[item].Hash === opts.hash) {
|
||||
url = url + list[item].Name
|
||||
this.ipfs.files.cat(url, (err, res) => {
|
||||
// Look for previous versions
|
||||
if (err || opts.previouses.indexOf(opts.hash) >= 0) return
|
||||
replyAsObj(res, true, (err, obj) => {
|
||||
if (!err && obj.previous) {
|
||||
// Delete if found
|
||||
this.delete({
|
||||
what: opts.what,
|
||||
hash: obj.previous,
|
||||
// Check for cyclic depdendency structures
|
||||
previouses: (opts.previouses || []).concat(opts.hash)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
return this.ipfs.files.rm(url, {}, err => {
|
||||
if (err) return done(err)
|
||||
this.ipfs.files.stat('/', (err, res) => {
|
||||
|
Loading…
Reference in New Issue
Block a user