Index: firmware/common/file.c =================================================================== --- firmware/common/file.c (revision 13812) +++ firmware/common/file.c (working copy) @@ -305,15 +305,15 @@ return fd * 10 - 1; file = &openfiles[fd]; -#ifdef HAVE_DIRCACHE - dircache_remove(name); -#endif rc = fat_remove(&(file->fatfile)); if ( rc < 0 ) { DEBUGF("Failed removing file: %d\n", rc); errno = EIO; return rc * 10 - 3; } +#ifdef HAVE_DIRCACHE + dircache_remove(name); +#endif file->size = 0; @@ -376,10 +376,7 @@ return - 5; file = &openfiles[fd]; -#ifdef HAVE_DIRCACHE - dircache_rename(path, newpath); -#endif - + rc = fat_rename(&file->fatfile, &dir->fatdir, nameptr, file->size, file->attr); #ifdef HAVE_MULTIVOLUME @@ -394,6 +391,9 @@ errno = EIO; return rc * 10 - 7; } +#ifdef HAVE_DIRCACHE + dircache_rename(path, newpath); +#endif rc = close(fd); if (rc<0) {