forked from TrueCloudLab/rclone
Make failed uploads not count as "Transferred" - fixes #708
This commit is contained in:
parent
20a429c048
commit
83ba59749f
4 changed files with 20 additions and 9 deletions
4
b2/b2.go
4
b2/b2.go
|
@ -799,9 +799,9 @@ func (f *Fs) purge(oldOnly bool) error {
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for object := range toBeDeleted {
|
for object := range toBeDeleted {
|
||||||
fs.Stats.Transferring(object.Name)
|
fs.Stats.Checking(object.Name)
|
||||||
checkErr(f.deleteByID(object.ID, object.Name))
|
checkErr(f.deleteByID(object.ID, object.Name))
|
||||||
fs.Stats.DoneTransferring(object.Name)
|
fs.Stats.DoneChecking(object.Name)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,11 +231,15 @@ func (s *StatsInfo) Transferring(remote string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoneTransferring removes a transfer from the stats
|
// DoneTransferring removes a transfer from the stats
|
||||||
func (s *StatsInfo) DoneTransferring(remote string) {
|
//
|
||||||
|
// if ok is true then it increments the transfers count
|
||||||
|
func (s *StatsInfo) DoneTransferring(remote string, ok bool) {
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
delete(s.transferring, remote)
|
delete(s.transferring, remote)
|
||||||
s.transfers++
|
if ok {
|
||||||
|
s.transfers++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account limits and accounts for one transfer
|
// Account limits and accounts for one transfer
|
||||||
|
|
|
@ -1017,8 +1017,11 @@ func CleanUp(f Fs) error {
|
||||||
func Cat(f Fs, w io.Writer) error {
|
func Cat(f Fs, w io.Writer) error {
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
return ListFn(f, func(o Object) {
|
return ListFn(f, func(o Object) {
|
||||||
|
var err error
|
||||||
Stats.Transferring(o.Remote())
|
Stats.Transferring(o.Remote())
|
||||||
defer Stats.DoneTransferring(o.Remote())
|
defer func() {
|
||||||
|
Stats.DoneTransferring(o.Remote(), err == nil)
|
||||||
|
}()
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
in, err := o.Open()
|
in, err := o.Open()
|
||||||
|
@ -1041,5 +1044,4 @@ func Cat(f Fs, w io.Writer) error {
|
||||||
ErrorLog(o, "Failed to send to output: %v", err)
|
ErrorLog(o, "Failed to send to output: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
11
fs/sync.go
11
fs/sync.go
|
@ -232,12 +232,14 @@ func (s *syncCopyMove) pairCopier(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup
|
||||||
}
|
}
|
||||||
src := pair.src
|
src := pair.src
|
||||||
Stats.Transferring(src.Remote())
|
Stats.Transferring(src.Remote())
|
||||||
|
var err error
|
||||||
if Config.DryRun {
|
if Config.DryRun {
|
||||||
Log(src, "Not copying as --dry-run")
|
Log(src, "Not copying as --dry-run")
|
||||||
} else {
|
} else {
|
||||||
s.processError(Copy(fdst, pair.dst, src))
|
err = Copy(fdst, pair.dst, src)
|
||||||
|
s.processError(err)
|
||||||
}
|
}
|
||||||
Stats.DoneTransferring(src.Remote())
|
Stats.DoneTransferring(src.Remote(), err == nil)
|
||||||
case <-s.abort:
|
case <-s.abort:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -259,6 +261,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
transferredOK := true
|
||||||
src := pair.src
|
src := pair.src
|
||||||
dst := pair.dst
|
dst := pair.dst
|
||||||
Stats.Transferring(src.Remote())
|
Stats.Transferring(src.Remote())
|
||||||
|
@ -267,6 +270,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)
|
||||||
err := Copy(fdst, dst, src)
|
err := Copy(fdst, dst, src)
|
||||||
s.processError(err)
|
s.processError(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
transferredOK = false
|
||||||
ErrorLog(src, "Not deleting as copy failed: %v", err)
|
ErrorLog(src, "Not deleting as copy failed: %v", err)
|
||||||
} else {
|
} else {
|
||||||
// Delete src if no error on copy
|
// Delete src if no error on copy
|
||||||
|
@ -293,6 +297,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)
|
||||||
Stats.Error()
|
Stats.Error()
|
||||||
ErrorLog(dst, "Couldn't move: %v", err)
|
ErrorLog(dst, "Couldn't move: %v", err)
|
||||||
s.processError(err)
|
s.processError(err)
|
||||||
|
transferredOK = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Debug(src, "Moved")
|
Debug(src, "Moved")
|
||||||
|
@ -300,7 +305,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)
|
||||||
} else {
|
} else {
|
||||||
doCopy()
|
doCopy()
|
||||||
}
|
}
|
||||||
Stats.DoneTransferring(src.Remote())
|
Stats.DoneTransferring(src.Remote(), transferredOK)
|
||||||
case <-s.abort:
|
case <-s.abort:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue