Skip to content

Commit 071de3f

Browse files
committed
update
1 parent 3c8eb53 commit 071de3f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

application/library/cloudbackup/cloudbackup.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ func (c *Cloudbackup) OnDelete(file string) {
113113
if !c.Filter(file) {
114114
return
115115
}
116+
relPath := strings.TrimPrefix(file, c.SourcePath)
117+
if len(relPath) == 0 || relPath == `/` || relPath == `\` {
118+
return
119+
}
116120
startTime := time.Now()
117-
objectName := path.Join(c.DestPath, strings.TrimPrefix(file, c.SourcePath))
121+
objectName := path.Join(c.DestPath, relPath)
118122
err := c.mgr.RemoveDir(context.Background(), objectName)
119123
if err != nil {
120124
log.Error(file + `: ` + err.Error())
@@ -133,8 +137,12 @@ func (c *Cloudbackup) OnRename(file string) {
133137
if !c.Filter(file) {
134138
return
135139
}
140+
relPath := strings.TrimPrefix(file, c.SourcePath)
141+
if len(relPath) == 0 || relPath == `/` || relPath == `\` {
142+
return
143+
}
136144
startTime := time.Now()
137-
objectName := path.Join(c.DestPath, strings.TrimPrefix(file, c.SourcePath))
145+
objectName := path.Join(c.DestPath, relPath)
138146
err := c.mgr.RemoveDir(context.Background(), objectName)
139147
if err != nil {
140148
log.Error(file + `: ` + err.Error())

0 commit comments

Comments
 (0)