384
384
SVN_ERR(svn_io_remove_file2(proto_l2p_index_path, FALSE, pool));
385
385
SVN_ERR(svn_io_remove_file2(proto_p2l_index_path, FALSE, pool));
387
/* Ensure that packed file is written to disk.*/
388
SVN_ERR(svn_io_file_flush_to_disk(context->pack_file, pool));
387
389
SVN_ERR(svn_io_file_close(context->pack_file, pool));
389
391
return SVN_NO_ERROR;
1656
1658
apr_pool_t *pool)
1658
1660
const char *pack_file_path, *manifest_file_path;
1659
svn_stream_t *pack_stream, *manifest_stream;
1661
apr_file_t *pack_file;
1662
apr_file_t *manifest_file;
1663
svn_stream_t *manifest_stream;
1660
1664
svn_revnum_t end_rev, rev;
1661
1665
apr_off_t next_offset;
1662
1666
apr_pool_t *iterpool;
1665
1669
pack_file_path = svn_dirent_join(pack_file_dir, PATH_PACKED, pool);
1666
1670
manifest_file_path = svn_dirent_join(pack_file_dir, PATH_MANIFEST, pool);
1668
/* Create the new directory and pack file. */
1669
SVN_ERR(svn_stream_open_writable(&pack_stream, pack_file_path, pool,
1672
/* Create the new directory and pack file.
1673
* Use unbuffered apr_file_t since we're going to write using 16kb
1675
SVN_ERR(svn_io_file_open(&pack_file, pack_file_path,
1676
APR_WRITE | APR_CREATE | APR_EXCL,
1677
APR_OS_DEFAULT, pool));
1672
1679
/* Create the manifest file. */
1673
SVN_ERR(svn_stream_open_writable(&manifest_stream, manifest_file_path,
1680
SVN_ERR(svn_io_file_open(&manifest_file, manifest_file_path,
1681
APR_WRITE | APR_BUFFERED | APR_CREATE | APR_EXCL,
1682
APR_OS_DEFAULT, pool));
1683
manifest_stream = svn_stream_from_aprfile2(manifest_file, TRUE, pool);
1676
1685
end_rev = start_rev + max_files_per_dir - 1;
1677
1686
next_offset = 0;
1699
1708
/* Copy all the bits from the rev file to the end of the pack file. */
1700
1709
SVN_ERR(svn_stream_open_readonly(&rev_stream, path, iterpool, iterpool));
1701
SVN_ERR(svn_stream_copy3(rev_stream, svn_stream_disown(pack_stream,
1710
SVN_ERR(svn_stream_copy3(rev_stream,
1711
svn_stream_from_aprfile2(pack_file, TRUE, pool),
1703
1712
cancel_func, cancel_baton, iterpool));
1715
/* Close stream over APR file. */
1716
SVN_ERR(svn_stream_close(manifest_stream));
1718
/* Ensure that pack file is written to disk. */
1719
SVN_ERR(svn_io_file_flush_to_disk(manifest_file, pool));
1720
SVN_ERR(svn_io_file_close(manifest_file, pool));
1706
1722
/* disallow write access to the manifest file */
1707
SVN_ERR(svn_stream_close(manifest_stream));
1708
1723
SVN_ERR(svn_io_set_file_read_only(manifest_file_path, FALSE, iterpool));
1710
SVN_ERR(svn_stream_close(pack_stream));
1725
/* Ensure that pack file is written to disk. */
1726
SVN_ERR(svn_io_file_flush_to_disk(pack_file, pool));
1727
SVN_ERR(svn_io_file_close(pack_file, pool));
1712
1729
svn_pool_destroy(iterpool);