Skip to content

Commit d884c29

Browse files
authored
Merge pull request #121 from mitre/fix-metadata-batch
Fix metadata batch
2 parents 9e1f678 + 2d68f6d commit d884c29

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

cmd/mount.go

+21-12
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,17 @@ func mount(cmd *cobra.Command, args []string) (err error) {
148148

149149
client := sdl.NewClient(endpoint, location, ngc, types)
150150
var accessions []*fuseralib.Accession
151+
var rootErr []byte
151152
if !eager {
152153
dot := 2000
153154
i := 0
154155
for dot < len(accs) {
155156
aa, err := client.GetMetadata(accs[i:dot])
156157
if err != nil {
157-
fmt.Println(err.Error())
158-
fmt.Println("List of accessions that failed in this batch:")
159-
fmt.Println(accs[i:dot])
158+
rootErr = append(rootErr, []byte(fmt.Sprintln(err.Error()))...)
159+
rootErr = append(rootErr, []byte("List of accessions that failed in this batch:\n")...)
160+
rootErr = append(rootErr, []byte(fmt.Sprintln(accs[i:dot]))...)
161+
fmt.Println(string(rootErr))
160162
} else {
161163
accessions = append(accessions, aa...)
162164
}
@@ -165,9 +167,10 @@ func mount(cmd *cobra.Command, args []string) (err error) {
165167
}
166168
aa, err := client.GetMetadata(accs[i:])
167169
if err != nil {
168-
fmt.Println(err.Error())
169-
fmt.Println("List of accessions that failed in this batch:")
170-
fmt.Println(accs[i:])
170+
rootErr = append(rootErr, []byte(fmt.Sprintln(err.Error()))...)
171+
rootErr = append(rootErr, []byte("List of accessions that failed in this batch:\n")...)
172+
rootErr = append(rootErr, []byte(fmt.Sprintln(accs[i:]))...)
173+
fmt.Println(string(rootErr))
171174
} else {
172175
accessions = append(accessions, aa...)
173176
}
@@ -177,9 +180,10 @@ func mount(cmd *cobra.Command, args []string) (err error) {
177180
for dot < len(accs) {
178181
aa, err := client.GetSignedURL(accs[i:dot])
179182
if err != nil {
180-
fmt.Println(err.Error())
181-
fmt.Println("List of accessions that failed in this batch:")
182-
fmt.Println(accs[i:dot])
183+
rootErr = append(rootErr, []byte(fmt.Sprintln(err.Error()))...)
184+
rootErr = append(rootErr, []byte("List of accessions that failed in this batch:\n")...)
185+
rootErr = append(rootErr, []byte(fmt.Sprintln(accs[i:dot]))...)
186+
fmt.Println(string(rootErr))
183187
} else {
184188
accessions = append(accessions, aa...)
185189
}
@@ -188,13 +192,18 @@ func mount(cmd *cobra.Command, args []string) (err error) {
188192
}
189193
aa, err := client.GetSignedURL(accs[i:])
190194
if err != nil {
191-
fmt.Println(err.Error())
192-
fmt.Println("List of accessions that failed in this batch:")
193-
fmt.Println(accs[i:])
195+
rootErr = append(rootErr, []byte(fmt.Sprintln(err.Error()))...)
196+
rootErr = append(rootErr, []byte("List of accessions that failed in this batch:\n")...)
197+
rootErr = append(rootErr, []byte(fmt.Sprintln(accs[i:]))...)
198+
fmt.Println(string(rootErr))
194199
} else {
195200
accessions = append(accessions, aa...)
196201
}
197202
}
203+
if len(accessions) == 0 {
204+
fmt.Println("It seems like none of the accessions were successful, fusera is shutting down.")
205+
os.Exit(1)
206+
}
198207
//
199208
opt := &fuseralib.Options{
200209
Signer: client,

0 commit comments

Comments
 (0)