@@ -218,7 +218,7 @@ func DownloadAnalyzerManagerIfNeeded(threadId int) error {
218218 checksumFilePath := filepath .Join (analyzerManagerDir , dependencies .ChecksumFileName )
219219 log .Info ("analyzer manager Checksum file path: " + checksumFilePath )
220220
221- exist , err := fileutils . IsFileExists (checksumFilePath , false )
221+ exist , err := IsFileExists (checksumFilePath , false )
222222 if err != nil {
223223 return err
224224 }
@@ -260,3 +260,33 @@ func getAnalyzerManagerRemoteDetails(downloadPath string) (server *config.Server
260260 // If not configured to download through a remote repository in Artifactory, download from releases.jfrog.io.
261261 return & config.ServerDetails {ArtifactoryUrl : coreutils .JfrogReleasesUrl }, downloadPath , nil
262262}
263+
264+ func GetFileInfo (path string , preserveSymLink bool ) (fileInfo os.FileInfo , err error ) {
265+ if preserveSymLink {
266+ fileInfo , err = os .Lstat (path )
267+ } else {
268+ fileInfo , err = os .Stat (path )
269+ }
270+ // We should not do CheckError here, because the error is checked by the calling functions.
271+ return
272+ }
273+
274+ // Check if path points at a file.
275+ // If path points at a symlink and `preserveSymLink == true`,
276+ // function will return `true` regardless of the symlink target
277+ func IsFileExists (path string , preserveSymLink bool ) (bool , error ) {
278+ fileInfo , err := GetFileInfo (path , preserveSymLink )
279+ if fileInfo != nil {
280+ log .Info ("file info: " + fileInfo .Name ())
281+ } else {
282+ log .Info ("file info is nil" )
283+ }
284+ if err != nil {
285+ log .Info ("error: " + err .Error ())
286+ if os .IsNotExist (err ) { // If doesn't exist, don't omit an error
287+ return false , nil
288+ }
289+ return false , errorutils .CheckError (err )
290+ }
291+ return ! fileInfo .IsDir (), nil
292+ }
0 commit comments