11package cmd
22
33import (
4+ "github.com/dustin/go-humanize"
45 "github.com/l3uddz/crop/config"
56 "github.com/l3uddz/crop/uploader"
67 "github.com/pkg/errors"
8+ "github.com/sirupsen/logrus"
79 "github.com/spf13/cobra"
810 "github.com/yale8848/gorpool"
911)
@@ -27,7 +29,6 @@ var uploadCmd = &cobra.Command{
2729 }
2830
2931 log := log .WithField ("uploader" , uploaderName )
30- log .Info ("Uploader commencing..." )
3132
3233 // create uploader
3334 upload , err := uploader .New (config .Config , & uploaderConfig , uploaderName )
@@ -40,8 +41,32 @@ var uploadCmd = &cobra.Command{
4041 if upload .ServiceAccountCount > 0 {
4142 upload .Log .WithField ("found_files" , upload .ServiceAccountCount ).
4243 Info ("Loaded service accounts" )
44+ } else {
45+ // no service accounts were loaded
46+ // check to see if any of the copy or move remote(s) are banned
47+ banned , expiry := upload .RemotesBanned (upload .Config .Remotes .Copy )
48+ if banned && ! expiry .IsZero () {
49+ // one of the copy remotes is banned, abort
50+ upload .Log .WithFields (logrus.Fields {
51+ "expires_time" : expiry ,
52+ "expires_in" : humanize .Time (expiry ),
53+ }).Warn ("Cannot proceed with upload as a copy remote is banned" )
54+ continue
55+ }
56+
57+ banned , expiry = upload .RemotesBanned ([]string {upload .Config .Remotes .Move })
58+ if banned && ! expiry .IsZero () {
59+ // the move remote is banned, abort
60+ upload .Log .WithFields (logrus.Fields {
61+ "expires_time" : expiry ,
62+ "expires_in" : humanize .Time (expiry ),
63+ }).Warn ("Cannot proceed with upload as the move remote is banned" )
64+ continue
65+ }
4366 }
4467
68+ log .Info ("Uploader commencing..." )
69+
4570 // refresh details about files to upload
4671 if err := upload .RefreshLocalFiles (); err != nil {
4772 upload .Log .WithError (err ).Error ("Failed refreshing details of files to upload" )
0 commit comments