]> git.saurik.com Git - redis.git/commitdiff
avoid bgsaving temp files
authorantirez <antirez@gmail.com>
Fri, 7 Jan 2011 22:51:31 +0000 (23:51 +0100)
committerantirez <antirez@gmail.com>
Fri, 7 Jan 2011 22:51:31 +0000 (23:51 +0100)
src/diskstore.c

index 447f10b36c4369a05e5a58037df3faed219d52a9..057bfc689c0121c5e5de82664794eec3594058b5 100644 (file)
@@ -190,7 +190,7 @@ int dsSet(redisDb *db, robj *key, robj *val) {
 
     len = dsKeyToPath(db,buf,key);
     memcpy(buf2,buf,len);
-    snprintf(buf2+len,sizeof(buf2)-len,"_%ld_%ld",(long)time(NULL),(long)val);
+    snprintf(buf2+len,sizeof(buf2)-len,"-%ld-%ld",(long)time(NULL),(long)val);
     while ((fp = fopen(buf2,"w")) == NULL) {
         if (errno == ENOSPC) {
             redisLog(REDIS_WARNING,"Diskstore: No space left on device. Please make room and wait 30 seconds for Redis to continue.");
@@ -401,6 +401,8 @@ void *dsRdbSave_thread(void *arg) {
                 readdir_r(dir,&de,&dp);
                 if (dp == NULL) break;
                 if (dp->d_name[0] == '.') continue;
+                /* If there is a '-' char in the file name, it's a temp file */
+                if (strchr(dp->d_name,'-') != NULL) continue;
 
                 /* Emit the SELECT DB opcode if needed. */
                 dbid = dsGetDbidFromFilename(dp->d_name);