julianf...@apache.org wrote on Tue, Mar 01, 2011 at 17:47:05 -0000: > Author: julianfoad > Date: Tue Mar 1 17:47:04 2011 > New Revision: 1075942 > > URL: http://svn.apache.org/viewvc?rev=1075942&view=rev > Log: > Make the pristine text store guarantee that a pristine text stream being > read will remain readable even if the text is deleted from the store. To > ensure that a recently deleted pristine file can be reinstated, on Windows > we rename it to a new unique name before deleting it. This is probably not > the most efficient way to work on Windows. ... > +/* Remove the file at FILE_ABSPATH in such a way that we could re-create a > + * new file of the same name at any time thereafter. > + * > + * On Windows, the file will not disappear immediately from the directory if > + * it is still being read so the best thing to do is first rename it to a > + * unique name. */ > +static svn_error_t * > +remove_file(const char *file_abspath, > + svn_wc__db_wcroot_t *wcroot, > + svn_boolean_t ignore_enoent, > + apr_pool_t *scratch_pool)
Currently, this function has only one caller, and it passes a pristine's abspath for FILE_ABSPATH. > +{ > +#if 1 /*def WIN32*/ > + svn_error_t *err; > + const char *temp_abspath; > + const char *temp_dir_abspath > + = pristine_get_tempdir(wcroot, scratch_pool, scratch_pool); > + > + /* To rename the file to a unique name in the temp dir, first create a > + * uniquely named file in the temp dir and then overwrite it. */ > + SVN_ERR(svn_io_open_unique_file3(NULL, &temp_abspath, temp_dir_abspath, > + svn_io_file_del_none, > + scratch_pool, scratch_pool)); Could you use here the basename of the pristine instead of requesting a random name? I think would be slightly more efficient. > + err = svn_io_file_rename(file_abspath, temp_abspath, scratch_pool); > + if (err && ignore_enoent && APR_STATUS_IS_ENOENT(err->apr_err)) > + svn_error_clear(err); > + else > + SVN_ERR(err); > + file_abspath = temp_abspath; > +#endif > + > + SVN_ERR(svn_io_remove_file2(file_abspath, ignore_enoent, scratch_pool)); > + > + return SVN_NO_ERROR; > +}