Changeset 5187

Show
Ignore:
Timestamp:
01/21/08 09:10:53 (6 months ago)
Author:
morris
Message:

Fix problem with setting file comments

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wired/trunk/wired/files.c

    r5166 r5187  
    11591159        file = wi_file_for_updating(commentpath); 
    11601160         
    1161         if(!file) 
     1161        if(!file) { 
     1162                wi_log_warn(WI_STR("Could not open %@: %m"), commentpath); 
     1163                wd_reply_error(); 
     1164                 
    11621165                return; 
     1166        } 
    11631167         
    11641168        tmpfile = wi_file_temporary_file(); 
     
    11661170        if(!tmpfile) { 
    11671171                wi_log_warn(WI_STR("Could not create a temporary file: %m")); 
     1172                wd_reply_error(); 
    11681173 
    11691174                return; 
     
    11741179                                          name,         WD_FILES_COMMENT_FIELD_SEPARATOR, 
    11751180                                          comment,      WD_FILES_COMMENT_SEPARATOR); 
    1176                  
    11771181                comments++; 
    11781182        } 
     
    11881192        } 
    11891193         
    1190         if(comments > 1) { 
     1194        if(comments > 0) { 
    11911195                wi_file_truncate(file, 0); 
    11921196                wi_file_seek(tmpfile, 0); 
     
    11941198                while((string = wi_file_read(tmpfile, WI_FILE_BUFFER_SIZE))) 
    11951199                        wi_file_write(file, WI_STR("%@"), string); 
     1200 
     1201                wi_file_close(file); 
     1202                wi_file_close(tmpfile); 
    11961203        } else { 
    11971204                /* clearing comment, and there are no more comments in the file, remove */