Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
shammishailaj committed Nov 12, 2020
2 parents d263447 + 7e948c4 commit 2c991af
Show file tree
Hide file tree
Showing 25 changed files with 839 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.63
0.0.66
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ require (
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
github.com/yookoala/gofast v0.4.0 // indirect
gopkg.in/djherbis/times.v1 v1.2.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ij
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/djherbis/times.v1 v1.2.0 h1:UCvDKl1L/fmBygl2Y7hubXCnY7t4Yj46ZrBFNUipFbM=
gopkg.in/djherbis/times.v1 v1.2.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.38.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
Expand Down
24 changes: 19 additions & 5 deletions pkg/utils/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,43 @@ package utils
import (
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"gopkg.in/djherbis/times.v1"
"io/ioutil"
"os"
"syscall"
//"syscall"
"time"
)

func (u *Utils) FileExists(path string) bool {
if _, err := os.Stat(path); os.IsNotExist(err) {
return false
}

return true
}

func (u *Utils) DeleteFileByAge(path string, minAgeForDeletion time.Duration) (bool,error) {
u.Log.Infof("Deleting file: %s", path)
fileStat, fileStatErr := os.Stat(path)
/*fileStat,*/_, fileStatErr := os.Stat(path)
if os.IsNotExist(fileStatErr) {
u.Log.Errorf("Could not find file %s. %s", path, fileStatErr.Error())
return false, fileStatErr
} else {
tFileCreationTime := fileStat.Sys().(*syscall.Stat_t).Ctimespec
fileCreationTime := time.Unix(tFileCreationTime.Sec, tFileCreationTime.Nsec)
t, err := times.Stat(path)
if err != nil {
log.Fatal(err.Error())
}

//tFileCreationTime := fileStat.Sys().(*syscall.Stat_t).Ctimespec
//fileCreationTime := time.Unix(tFileCreationTime.Sec, tFileCreationTime.Nsec)
var fileCreationTime time.Time
if t.HasBirthTime() {
fileCreationTime = t.BirthTime()
}
if t.HasChangeTime() {
fileCreationTime = t.ChangeTime()
}

tCurrentTime := time.Now()
tFileAgeForDeletion := int64(minAgeForDeletion) // 10 secs X 60 = 600 secs OR 10 mins

Expand Down
28 changes: 28 additions & 0 deletions vendor/gopkg.in/djherbis/times.v1/.travis.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/gopkg.in/djherbis/times.v1/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/gopkg.in/djherbis/times.v1/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions vendor/gopkg.in/djherbis/times.v1/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

149 changes: 149 additions & 0 deletions vendor/gopkg.in/djherbis/times.v1/ctime_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions vendor/gopkg.in/djherbis/times.v1/js.cover.dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions vendor/gopkg.in/djherbis/times.v1/js.cover.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2c991af

Please sign in to comment.