[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1075942 - in /subversion/trunk: notes/wc-ng/pristine-store subversion/libsvn_wc/wc_db.h subversion/libsvn_wc/wc_db_pristine.c subversion/tests/libsvn_wc/pristine-store-test.c

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Wed, 2 Mar 2011 05:32:46 +0200

julianfoad_at_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;
> +}
Received on 2011-03-02 04:33:51 CET

This is an archived mail posted to the Subversion Dev mailing list.