@@ -108,12 +108,13 @@ func (b *Builder) compileCore() (*paths.Path, paths.PathList, error) {
108
108
return true
109
109
}
110
110
111
- // If there is an archived core in the current build cache, use it
112
- if _ , err := buildcache .New (b .coreBuildCachePath ).GetOrCreate (archivedCoreName ); errors .Is (err , buildcache .CreateDirErr ) {
113
- return nil , nil , errors .New (i18n .Tr ("creating core cache folder: %s" , err ))
114
- }
115
111
targetArchivedCore = b .coreBuildCachePath .Join (archivedCoreName , "core.a" )
116
112
if canUseArchivedCore (targetArchivedCore ) {
113
+ // Update timestamp of the cache folder to extend expire time
114
+ if _ , err := buildcache .New (b .coreBuildCachePath ).GetOrCreate (archivedCoreName ); errors .Is (err , buildcache .CreateDirErr ) {
115
+ return nil , nil , errors .New (i18n .Tr ("creating core cache folder: %s" , err ))
116
+ }
117
+
117
118
// use archived core
118
119
if b .logger .Verbose () {
119
120
b .logger .Info (i18n .Tr ("Using precompiled core: %[1]s" , targetArchivedCore ))
@@ -151,17 +152,23 @@ func (b *Builder) compileCore() (*paths.Path, paths.PathList, error) {
151
152
152
153
// archive core.a
153
154
if targetArchivedCore != nil && ! b .onlyUpdateCompilationDatabase {
154
- err := archiveFile .CopyTo (targetArchivedCore )
155
- if b .logger .Verbose () {
156
- if err == nil {
157
- b .logger .Info (i18n .Tr ("Archiving built core (caching) in: %[1]s" , targetArchivedCore ))
158
- } else if os .IsNotExist (err ) {
159
- b .logger .Info (i18n .Tr ("Unable to cache built core, please tell %[1]s maintainers to follow %[2]s" ,
160
- b .actualPlatform ,
161
- "https://arduino.github.io/arduino-cli/latest/platform-specification/#recipes-to-build-the-corea-archive-file" ))
162
- } else {
155
+ if err := targetArchivedCore .Parent ().MkdirAll (); err != nil {
156
+ if b .logger .Verbose () {
163
157
b .logger .Info (i18n .Tr ("Error archiving built core (caching) in %[1]s: %[2]s" , targetArchivedCore , err ))
164
158
}
159
+ } else {
160
+ err := archiveFile .CopyTo (targetArchivedCore )
161
+ if b .logger .Verbose () {
162
+ if err == nil {
163
+ b .logger .Info (i18n .Tr ("Archiving built core (caching) in: %[1]s" , targetArchivedCore ))
164
+ } else if os .IsNotExist (err ) {
165
+ b .logger .Info (i18n .Tr ("Unable to cache built core, please tell %[1]s maintainers to follow %[2]s" ,
166
+ b .actualPlatform ,
167
+ "https://arduino.github.io/arduino-cli/latest/platform-specification/#recipes-to-build-the-corea-archive-file" ))
168
+ } else {
169
+ b .logger .Info (i18n .Tr ("Error archiving built core (caching) in %[1]s: %[2]s" , targetArchivedCore , err ))
170
+ }
171
+ }
165
172
}
166
173
}
167
174
0 commit comments