Commit ce76ad36 authored by Sandeep S. Shewalkar's avatar Sandeep S. Shewalkar
Browse files

changes in Download Helper

altered modified time for the file 
parent f7cd7523
Branches
1 merge request!52changes in Download Helper
Showing with 29 additions and 0 deletions
......@@ -117,6 +117,12 @@ func DownloadFile(sourcePath, destinationPath, jwtToken string, retryCnt int) (b
logginghelper.LogError("Error while closing response : ", closeErr)
}
logginghelper.LogDebug("DownloadFile : Download Successful")
timeStampChangeError := changeFileTimes(resp, destinationPath)
if timeStampChangeError != nil {
logginghelper.LogError("Error while changing timestamp for file : ", destinationPath, " : ", timeStampChangeError)
}
DeleteBackup(destinationPath)
logginghelper.LogDebug("OUT : DownloadFile")
return true, nil
......@@ -197,3 +203,26 @@ func DeleteBackup(filePath string) error {
logginghelper.LogDebug("OUT : DeleteBackup")
return nil
}
func changeFileTimes(resp *grab.Response, destination string) error {
logginghelper.LogDebug("IN : ChangeFileTimes")
timeHeader := resp.HTTPResponse.Header.Get("Last-Modified")
logginghelper.LogInfo("Header Time:", timeHeader)
timeUTC, parseError := time.Parse("Mon, 02 Jan 2006 15:04:05 GMT", timeHeader)
if parseError != nil {
logginghelper.LogError(parseError)
return parseError
}
localtime := timeUTC.Local()
logginghelper.LogInfo("Local Time:", localtime)
changeError := os.Chtimes(destination, localtime, localtime)
if changeError != nil {
logginghelper.LogError(changeError)
return changeError
}
logginghelper.LogDebug("OUT : ChangeFileTimes")
return nil
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment