Skip to content

Commit 7104eca

Browse files
authored
Update cache_disk.c (#330)
- Updated disk cache templates to replace all instances of discovered variables instead of just the first instance.
1 parent 2a5bfb9 commit 7104eca

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

lib/cache_disk.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -196,29 +196,29 @@ static void _mapcache_cache_disk_tilecache_tile_key(mapcache_context *ctx, mapca
196196
tile->tileset->format?tile->tileset->format->extension:"png");
197197
} else {
198198
*path = cache->filename_template;
199-
*path = mapcache_util_str_replace(ctx->pool,*path, "{tileset}", tile->tileset->name);
200-
*path = mapcache_util_str_replace(ctx->pool,*path, "{grid}", tile->grid_link->grid->name);
201-
*path = mapcache_util_str_replace(ctx->pool,*path, "{ext}",
199+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{tileset}", tile->tileset->name);
200+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{grid}", tile->grid_link->grid->name);
201+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{ext}",
202202
tile->tileset->format?tile->tileset->format->extension:"png");
203203
if(strstr(*path,"{x}"))
204-
*path = mapcache_util_str_replace(ctx->pool,*path, "{x}",
204+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{x}",
205205
apr_psprintf(ctx->pool,"%d",tile->x));
206206
else
207-
*path = mapcache_util_str_replace(ctx->pool,*path, "{inv_x}",
207+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{inv_x}",
208208
apr_psprintf(ctx->pool,"%d",
209209
tile->grid_link->grid->levels[tile->z]->maxx - tile->x - 1));
210210
if(strstr(*path,"{y}"))
211-
*path = mapcache_util_str_replace(ctx->pool,*path, "{y}",
211+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{y}",
212212
apr_psprintf(ctx->pool,"%d",tile->y));
213213
else
214-
*path = mapcache_util_str_replace(ctx->pool,*path, "{inv_y}",
214+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{inv_y}",
215215
apr_psprintf(ctx->pool,"%d",
216216
tile->grid_link->grid->levels[tile->z]->maxy - tile->y - 1));
217217
if(strstr(*path,"{z}"))
218-
*path = mapcache_util_str_replace(ctx->pool,*path, "{z}",
218+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{z}",
219219
apr_psprintf(ctx->pool,"%d",tile->z));
220220
else
221-
*path = mapcache_util_str_replace(ctx->pool,*path, "{inv_z}",
221+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{inv_z}",
222222
apr_psprintf(ctx->pool,"%d",
223223
tile->grid_link->grid->nlevels - tile->z - 1));
224224
if(tile->dimensions && strstr(*path,"{dim")) {
@@ -245,10 +245,10 @@ static void _mapcache_cache_disk_tilecache_tile_key(mapcache_context *ctx, mapca
245245
dimstring = apr_pstrcat(ctx->pool,dimstring,"#",entry->dimension->name,"#",dimval,NULL);
246246
single_dim = apr_pstrcat(ctx->pool,"{dim:",entry->dimension->name,"}",NULL);
247247
if(strstr(*path,single_dim)) {
248-
*path = mapcache_util_str_replace(ctx->pool,*path, single_dim, dimval);
248+
*path = mapcache_util_str_replace_all(ctx->pool,*path, single_dim, dimval);
249249
}
250250
}
251-
*path = mapcache_util_str_replace(ctx->pool,*path, "{dim}", dimstring);
251+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{dim}", dimstring);
252252
}
253253
}
254254
if(!*path) {
@@ -260,30 +260,30 @@ static void _mapcache_cache_disk_template_tile_key(mapcache_context *ctx, mapcac
260260
{
261261

262262
*path = cache->filename_template;
263-
*path = mapcache_util_str_replace(ctx->pool,*path, "{tileset}", tile->tileset->name);
264-
*path = mapcache_util_str_replace(ctx->pool,*path, "{grid}", tile->grid_link->grid->name);
265-
*path = mapcache_util_str_replace(ctx->pool,*path, "{ext}",
263+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{tileset}", tile->tileset->name);
264+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{grid}", tile->grid_link->grid->name);
265+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{ext}",
266266
tile->tileset->format?tile->tileset->format->extension:"png");
267267

268268
if(strstr(*path,"{x}"))
269-
*path = mapcache_util_str_replace(ctx->pool,*path, "{x}",
269+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{x}",
270270
apr_psprintf(ctx->pool,"%d",tile->x));
271271
else
272-
*path = mapcache_util_str_replace(ctx->pool,*path, "{inv_x}",
272+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{inv_x}",
273273
apr_psprintf(ctx->pool,"%d",
274274
tile->grid_link->grid->levels[tile->z]->maxx - tile->x - 1));
275275
if(strstr(*path,"{y}"))
276-
*path = mapcache_util_str_replace(ctx->pool,*path, "{y}",
276+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{y}",
277277
apr_psprintf(ctx->pool,"%d",tile->y));
278278
else
279-
*path = mapcache_util_str_replace(ctx->pool,*path, "{inv_y}",
279+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{inv_y}",
280280
apr_psprintf(ctx->pool,"%d",
281281
tile->grid_link->grid->levels[tile->z]->maxy - tile->y - 1));
282282
if(strstr(*path,"{z}"))
283-
*path = mapcache_util_str_replace(ctx->pool,*path, "{z}",
283+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{z}",
284284
apr_psprintf(ctx->pool,"%d",tile->z));
285285
else
286-
*path = mapcache_util_str_replace(ctx->pool,*path, "{inv_z}",
286+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{inv_z}",
287287
apr_psprintf(ctx->pool,"%d",
288288
tile->grid_link->grid->nlevels - tile->z - 1));
289289
if(tile->dimensions && strstr(*path,"{dim")) {
@@ -310,10 +310,10 @@ static void _mapcache_cache_disk_template_tile_key(mapcache_context *ctx, mapcac
310310
dimstring = apr_pstrcat(ctx->pool,dimstring,"#",entry->dimension->name,"#",dimval,NULL);
311311
single_dim = apr_pstrcat(ctx->pool,"{dim:",entry->dimension->name,"}",NULL);
312312
if(strstr(*path,single_dim)) {
313-
*path = mapcache_util_str_replace(ctx->pool,*path, single_dim, dimval);
313+
*path = mapcache_util_str_replace_all(ctx->pool,*path, single_dim, dimval);
314314
}
315315
}
316-
*path = mapcache_util_str_replace(ctx->pool,*path, "{dim}", dimstring);
316+
*path = mapcache_util_str_replace_all(ctx->pool,*path, "{dim}", dimstring);
317317
}
318318

319319
if(!*path) {

0 commit comments

Comments
 (0)