Skip to content

Commit

Permalink
Bug fix for "Cannot invoke method getLastDownloaded() on null object"
Browse files Browse the repository at this point in the history
  • Loading branch information
jainishshah17 committed Mar 25, 2019
1 parent e6299d0 commit 39fe68c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions archive/archiveOldArtifacts/archiveOldArtifacts.groovy
Expand Up @@ -16,6 +16,7 @@

import org.artifactory.exception.CancelException
import org.artifactory.fs.StatsInfo
import org.artifactory.model.xstream.fs.StatsImpl
import org.artifactory.md.Properties
import org.artifactory.repo.RepoPath
import org.artifactory.repo.RepoPathFactory
Expand Down Expand Up @@ -376,6 +377,13 @@ boolean checkArchiveTimingPolicies(
if (lastDownloadedDays != 0) {
// Get the StatsInfo on the item
def statsInfo = (StatsInfo) repositories.getStats(artifact)

// If artifact is never downloaded
if (statsInfo == null){
statsInfo = new StatsImpl()
statsInfo.lastDownloaded = itemInfo.getCreated()
}

log.debug('Artifact {} stats info: {}', artifact, statsInfo)

// Get the last downloaded date
Expand Down

0 comments on commit 39fe68c

Please sign in to comment.