Skip to content

Commit

Permalink
Feat: add root folder alert (#21)
Browse files Browse the repository at this point in the history
* fix: add root folder alert
  • Loading branch information
fangbinwei authored Aug 7, 2024
1 parent 0aa5c83 commit 83a47e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (

func main() {
defer utils.TimeCost()()
if config.Folder == "/" {
fmt.Println("You should not upload the root directory, use ./ instead. 通常来说, 你不应该上传根目录, 也许你是要配置 ./")
os.Exit(1)
}

if !config.SkipSetting {
operation.SetStaticWebsiteConfig()
Expand Down
8 changes: 7 additions & 1 deletion operation/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package operation

import (
"fmt"
"os"
"path"
"strings"
"sync"
Expand All @@ -20,7 +21,12 @@ type UploadedObject struct {

// UploadObjects upload files to OSS
func UploadObjects(root string, bucket *oss.Bucket, records <-chan utils.FileInfoType, i *IncrementalConfig) ([]UploadedObject, []error) {
root = path.Clean(root) + "/"
if root == "/" {
fmt.Println("You should not upload the root directory, use ./ instead. 通常来说, 你不应该上传根目录, 也许你是要配置 ./")
os.Exit(1)
} else {
root = path.Clean(root) + "/"
}

var sw sync.WaitGroup
var errorMutex sync.Mutex
Expand Down

0 comments on commit 83a47e5

Please sign in to comment.