use tracker
This commit is contained in:
parent
734e90c960
commit
c5b5a60d4e
@ -129,11 +129,14 @@ func RestoreCollections(
|
|||||||
return dcs[i].FullPath().String() < dcs[j].FullPath().String()
|
return dcs[i].FullPath().String() < dcs[j].FullPath().String()
|
||||||
})
|
})
|
||||||
|
|
||||||
parentPermissions := map[string][]UserPermission{}
|
var (
|
||||||
|
et = errs.Tracker()
|
||||||
|
parentPermissions = map[string][]UserPermission{}
|
||||||
|
)
|
||||||
|
|
||||||
// Iterate through the data collections and restore the contents of each
|
// Iterate through the data collections and restore the contents of each
|
||||||
for _, dc := range dcs {
|
for _, dc := range dcs {
|
||||||
if errs.Err() != nil {
|
if et.Err() != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +162,7 @@ func RestoreCollections(
|
|||||||
opts.RestorePermissions,
|
opts.RestorePermissions,
|
||||||
errs)
|
errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(err)
|
et.Add(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range folderPerms {
|
for k, v := range folderPerms {
|
||||||
@ -178,10 +181,10 @@ func RestoreCollections(
|
|||||||
support.Restore,
|
support.Restore,
|
||||||
len(dcs),
|
len(dcs),
|
||||||
restoreMetrics,
|
restoreMetrics,
|
||||||
errs.Err(),
|
et.Err(),
|
||||||
dest.ContainerName)
|
dest.ContainerName)
|
||||||
|
|
||||||
return status, errs.Err()
|
return status, et.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreCollection handles restoration of an individual collection.
|
// RestoreCollection handles restoration of an individual collection.
|
||||||
@ -256,11 +259,13 @@ func RestoreCollection(
|
|||||||
return metrics, folderPerms, permissionIDMappings, clues.Wrap(err, "creating folders for restore")
|
return metrics, folderPerms, permissionIDMappings, clues.Wrap(err, "creating folders for restore")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore items from the collection
|
var (
|
||||||
items := dc.Items(ctx, nil) // TODO: fault.Errors instead of nil
|
et = errs.Tracker()
|
||||||
|
items = dc.Items(ctx, errs)
|
||||||
|
)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if errs.Err() != nil {
|
if et.Err() != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +280,7 @@ func RestoreCollection(
|
|||||||
|
|
||||||
itemPath, err := dc.FullPath().Append(itemData.UUID(), true)
|
itemPath, err := dc.FullPath().Append(itemData.UUID(), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(clues.Wrap(err, "appending item to full path").WithClues(ctx))
|
et.Add(clues.Wrap(err, "appending item to full path").WithClues(ctx))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +302,7 @@ func RestoreCollection(
|
|||||||
copyBuffer,
|
copyBuffer,
|
||||||
source)
|
source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(err)
|
et.Add(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +326,7 @@ func RestoreCollection(
|
|||||||
|
|
||||||
permsFile, err := dc.Fetch(ctx, metaName)
|
permsFile, err := dc.Fetch(ctx, metaName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(clues.Wrap(err, "getting item metadata"))
|
et.Add(clues.Wrap(err, "getting item metadata"))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +335,7 @@ func RestoreCollection(
|
|||||||
metaReader.Close()
|
metaReader.Close()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(clues.Wrap(err, "deserializing item metadata"))
|
et.Add(clues.Wrap(err, "deserializing item metadata"))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +348,7 @@ func RestoreCollection(
|
|||||||
meta.Permissions,
|
meta.Permissions,
|
||||||
permissionIDMappings)
|
permissionIDMappings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(clues.Wrap(err, "restoring item permissions"))
|
et.Add(clues.Wrap(err, "restoring item permissions"))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +368,7 @@ func RestoreCollection(
|
|||||||
|
|
||||||
meta, err := getMetadata(metaReader)
|
meta, err := getMetadata(metaReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(clues.Wrap(err, "getting directory metadata").WithClues(ctx))
|
et.Add(clues.Wrap(err, "getting directory metadata").WithClues(ctx))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +391,7 @@ func RestoreCollection(
|
|||||||
copyBuffer,
|
copyBuffer,
|
||||||
source)
|
source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(err)
|
et.Add(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +407,7 @@ func RestoreCollection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return metrics, folderPerms, permissionIDMappings, errs.Err()
|
return metrics, folderPerms, permissionIDMappings, et.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// createRestoreFoldersWithPermissions creates the restore folder hierarchy in
|
// createRestoreFoldersWithPermissions creates the restore folder hierarchy in
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user