@@ -1267,20 +1267,6 @@ func isConfigFile(filePath string) (useConfigMap bool, readonly bool, skip bool)
1267
1267
// checkIsEmptyDir checks if filepath is empty
1268
1268
func checkIsEmptyDir (filePath string ) (bool , error ) {
1269
1269
log .Debugf ("checkIsEmptyDir of File : %v" , filePath )
1270
- var dirFilePath string = ""
1271
- fi , err := os .Stat (filePath )
1272
- if errors .Is (err , os .ErrNotExist ) {
1273
- log .Errorf ("filePath %v does not exist!" , filePath )
1274
- return false , err
1275
- }
1276
- mode := fi .Mode ()
1277
- if mode .IsDir () {
1278
- dirFilePath = filePath
1279
- log .Debugf ("filePath %v is directory!" , dirFilePath )
1280
- } else {
1281
- dirFilePath = filepath .Dir (filePath )
1282
- log .Debugf ("dirname of filePath is %v !" , dirFilePath )
1283
- }
1284
1270
files , err := os .ReadDir (filePath )
1285
1271
if err != nil {
1286
1272
log .Errorf ("ReadDir of %v failed !" ,filePath );
@@ -1297,7 +1283,8 @@ func checkIsEmptyDir(filePath string) (bool, error) {
1297
1283
// not empty
1298
1284
return false , nil
1299
1285
}
1300
- _ , err := checkIsEmptyDir (filepath .Join (dirFilePath ,file .Name ()))
1286
+ // recurse directory
1287
+ _ , err := checkIsEmptyDir (filepath .Join (filePath ,file .Name ()))
1301
1288
if err != nil {
1302
1289
log .Debugf ("Recursive checkIsEmptyDir return err %v for %v !" ,err , file );
1303
1290
return false , err
0 commit comments