@@ -16,6 +16,7 @@ const (
16
16
17
17
type File struct {
18
18
Name string
19
+ Size int64
19
20
FullPath string
20
21
BasePath string
21
22
Uploaded bool
@@ -96,28 +97,33 @@ func refreshFileList() {
96
97
97
98
var refreshedFileList []File
98
99
99
- for _ , f := range folders {
100
- fileBasePath := fmt .Sprintf ("%s/%s" , root , f .Name ())
101
- fs , err := os .ReadDir (fileBasePath )
102
- if err != nil {
103
- log .Fatal (err )
104
- }
100
+ for _ , file := range folders {
101
+ fullPath := fmt .Sprintf ("%s/%s" , root , file .Name ())
105
102
106
- for _ , file := range fs {
107
- fullPath := fmt .Sprintf ("%s/%s/%s" , root , f .Name (), file .Name ())
103
+ if strings .HasSuffix (file .Name (), ".mkv" ) {
104
+ uploaded := false
105
+ if _ , err := os .Stat (fmt .Sprintf ("%s/.%s-uploaded" , root , file .Name ())); err == nil {
106
+ uploaded = true
107
+ }
108
108
109
- if strings .HasSuffix (file .Name (), ".mkv" ) {
110
- uploaded := false
111
- if _ , err := os .Stat (fmt .Sprintf ("%s/.%s-uploaded" , fileBasePath , file .Name ())); err == nil {
112
- uploaded = true
113
- }
114
- refreshedFileList = append (refreshedFileList , File {
115
- Name : file .Name (),
116
- BasePath : fileBasePath ,
117
- FullPath : fullPath ,
118
- Uploaded : uploaded ,
119
- })
109
+ fileInfo , err := file .Info ()
110
+ if err != nil {
111
+ continue
120
112
}
113
+
114
+ // If size is smaller than 5 MegaByte, skip for now (is 0 if still not uploaded; skipping bad videos too)
115
+ if fileInfo .Size () < 5 << 20 {
116
+ fmt .Printf ("%s video too small, don't think should upload (%d bytes)\n " , file .Name (), fileInfo .Size ())
117
+ continue
118
+ }
119
+
120
+ refreshedFileList = append (refreshedFileList , File {
121
+ Name : file .Name (),
122
+ Size : fileInfo .Size (),
123
+ BasePath : root ,
124
+ FullPath : fullPath ,
125
+ Uploaded : uploaded ,
126
+ })
121
127
}
122
128
}
123
129
0 commit comments