[mapserver-commits] r12858 - trunk/mapserver/mapcache/src

svn at osgeo.org svn at osgeo.org
Tue Dec 6 11:58:20 EST 2011


Author: tbonfort
Date: 2011-12-06 08:58:19 -0800 (Tue, 06 Dec 2011)
New Revision: 12858

Modified:
   trunk/mapserver/mapcache/src/cache_disk.c
Log:
simplify tile deletion (don't open file before deleting it)


Modified: trunk/mapserver/mapcache/src/cache_disk.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_disk.c	2011-12-06 16:26:04 UTC (rev 12857)
+++ trunk/mapserver/mapcache/src/cache_disk.c	2011-12-06 16:58:19 UTC (rev 12858)
@@ -162,25 +162,12 @@
    apr_status_t ret;
    char errmsg[120];
    char *filename;
-   apr_file_t *f;
    _mapcache_cache_disk_tile_key(ctx, tile, &filename);
    GC_CHECK_ERROR(ctx);
 
-   /* delete the tile file if it already exists */
-   if((ret = apr_file_open(&f, filename,APR_FOPEN_READ,APR_OS_DEFAULT, ctx->pool)) == APR_SUCCESS) {
-      apr_file_close(f);
-      ret = apr_file_remove(filename,ctx->pool);
-      if(ret != APR_SUCCESS) {
-         ctx->set_error(ctx, 500,  "failed to remove existing file %s: %s",filename, apr_strerror(ret,errmsg,120));
-         return; /* we could not delete the file */
-      }
-   } else {
-      int code = 500;
-      if(ret == ENOENT) {
-         code = 404;
-      }
-      ctx->set_error(ctx, code,  "failed to remove file %s: %s",filename, apr_strerror(ret,errmsg,120));
-      return; /* we could not open the file */
+   ret = apr_file_remove(filename,ctx->pool);
+   if(ret != APR_SUCCESS && ret != ENOENT) {
+      ctx->set_error(ctx, 500,  "failed to remove file %s: %s",filename, apr_strerror(ret,errmsg,120));
    }
 }
 
@@ -314,14 +301,9 @@
    }
    *hackptr2 = '/';
 
-   /* delete the tile file if it already exists */
-   if((ret = apr_file_open(&f, filename,APR_FOPEN_READ,APR_OS_DEFAULT, ctx->pool)) == APR_SUCCESS) {
-      apr_file_close(f);
-      ret = apr_file_remove(filename,ctx->pool);
-      if(ret != APR_SUCCESS) {
-         ctx->set_error(ctx, 500,  "failed to remove existing file %s: %s",filename, apr_strerror(ret,errmsg,120));
-         return; /* we could not delete the file */
-      }
+   ret = apr_file_remove(filename,ctx->pool);
+   if(ret != APR_SUCCESS && ret != ENOENT) {
+      ctx->set_error(ctx, 500,  "failed to remove file %s: %s",filename, apr_strerror(ret,errmsg,120));
    }
 
   



More information about the mapserver-commits mailing list