@@ -26,6 +26,7 @@ import (
26
26
var (
27
27
noBLOBBERS = errors .New ("No Blobbers set in this allocation" )
28
28
notInitialized = common .NewError ("sdk_not_initialized" , "Please call InitStorageSDK Init and use GetAllocation to get the allocation object" )
29
+ underRepair = common .NewError ("allocaton_under_repair" , "Allocation is under repair, Please try again later" )
29
30
)
30
31
31
32
type MetaOperation struct {
@@ -83,12 +84,21 @@ type Allocation struct {
83
84
mutex * sync.Mutex
84
85
downloadProgressMap map [string ]* DownloadRequest
85
86
initialized bool
87
+ underRepair bool
88
+ }
89
+
90
+ func (a * Allocation ) UnderRepair () bool {
91
+ return a .underRepair
86
92
}
87
93
88
94
func (a * Allocation ) GetStats () * AllocationStats {
89
95
return a .Stats
90
96
}
91
97
98
+ func (a * Allocation ) UpdateRepairStatus (value bool ) {
99
+ a .underRepair = value
100
+ }
101
+
92
102
func (a * Allocation ) InitAllocation () {
93
103
// if a.uploadChan != nil {
94
104
// close(a.uploadChan)
@@ -173,6 +183,9 @@ func (a *Allocation) uploadOrUpdateFile(localpath string, remotepath string, sta
173
183
if ! a .isInitialized () {
174
184
return notInitialized
175
185
}
186
+ if a .UnderRepair () {
187
+ return underRepair
188
+ }
176
189
fileInfo , err := os .Stat (localpath )
177
190
if err != nil {
178
191
return fmt .Errorf ("Local file error: %s" , err .Error ())
@@ -236,6 +249,9 @@ func (a *Allocation) downloadFile(localPath string, remotePath string, contentMo
236
249
if ! a .isInitialized () {
237
250
return notInitialized
238
251
}
252
+ if a .UnderRepair () {
253
+ return underRepair
254
+ }
239
255
if stat , err := os .Stat (localPath ); err == nil {
240
256
if ! stat .IsDir () {
241
257
return fmt .Errorf ("Local path is not a directory '%s'" , localPath )
@@ -437,6 +453,9 @@ func (a *Allocation) DeleteFile(path string) error {
437
453
if ! a .isInitialized () {
438
454
return notInitialized
439
455
}
456
+ if a .UnderRepair () {
457
+ return underRepair
458
+ }
440
459
if len (path ) == 0 {
441
460
return common .NewError ("invalid_path" , "Invalid path for the list" )
442
461
}
@@ -577,6 +596,9 @@ func (a *Allocation) downloadFromAuthTicket(localPath string, authTicket string,
577
596
if ! a .isInitialized () {
578
597
return notInitialized
579
598
}
599
+ if a .UnderRepair () {
600
+ return underRepair
601
+ }
580
602
sEnc , err := base64 .StdEncoding .DecodeString (authTicket )
581
603
if err != nil {
582
604
return common .NewError ("auth_ticket_decode_error" , "Error decoding the auth ticket." + err .Error ())
0 commit comments