repo: Create uncompressed-object-cache dir dynamically
Having the `uncompressed-object-cache` directory in `archive` repos by default is clutter; the functionality should be considered deprecated. Now we only create the directory if we're doing a checkout with the cache enabled. Closes: #1446 Approved by: jlebon
This commit is contained in:
parent
2e95e06616
commit
88d27fb3f1
|
|
@ -89,6 +89,17 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
|
|||
if (!glnx_fchmod (tmpf.fd, file_mode, error))
|
||||
return FALSE;
|
||||
|
||||
if (self->uncompressed_objects_dir_fd == -1)
|
||||
{
|
||||
if (!glnx_shutil_mkdir_p_at (self->repo_dir_fd, "uncompressed-objects-cache", 0755,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
if (!glnx_opendirat (self->repo_dir_fd, "uncompressed-objects-cache", TRUE,
|
||||
&self->uncompressed_objects_dir_fd,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_ostree_repo_ensure_loose_objdir_at (self->uncompressed_objects_dir_fd,
|
||||
loose_path,
|
||||
cancellable, error))
|
||||
|
|
@ -420,7 +431,11 @@ checkout_file_hardlink (OstreeRepo *self,
|
|||
int srcfd = _ostree_repo_mode_is_bare (self->mode) ?
|
||||
self->objects_dir_fd : self->uncompressed_objects_dir_fd;
|
||||
|
||||
if (linkat (srcfd, loose_path, destination_dfd, destination_name, 0) == 0)
|
||||
if (srcfd == -1)
|
||||
{
|
||||
/* Fall through; we don't have an uncompressed object cache */
|
||||
}
|
||||
else if (linkat (srcfd, loose_path, destination_dfd, destination_name, 0) == 0)
|
||||
ret_result = HARDLINK_RESULT_LINKED;
|
||||
else if (!options->no_copy_fallback && (errno == EMLINK || errno == EXDEV || errno == EPERM))
|
||||
{
|
||||
|
|
@ -430,6 +445,7 @@ checkout_file_hardlink (OstreeRepo *self,
|
|||
}
|
||||
else if (allow_noent && errno == ENOENT)
|
||||
{
|
||||
/* Fall through */
|
||||
}
|
||||
else if (errno == EEXIST)
|
||||
{
|
||||
|
|
@ -1071,6 +1087,19 @@ checkout_tree_at (OstreeRepo *self,
|
|||
}
|
||||
}
|
||||
|
||||
/* Uncompressed archive caches; should be considered deprecated */
|
||||
const gboolean can_cache = (options->enable_uncompressed_cache
|
||||
&& self->enable_uncompressed_cache);
|
||||
if (can_cache
|
||||
&& !_ostree_repo_mode_is_bare (self->mode)
|
||||
&& self->uncompressed_objects_dir_fd < 0)
|
||||
{
|
||||
self->uncompressed_objects_dir_fd =
|
||||
glnx_opendirat_with_errno (self->repo_dir_fd, "uncompressed-objects-cache", TRUE);
|
||||
if (self->uncompressed_objects_dir_fd < 0 && errno != ENOENT)
|
||||
return glnx_throw_errno_prefix (error, "opendir(uncompressed-objects-cache)");
|
||||
}
|
||||
|
||||
/* Special case handling for subpath of a non-directory */
|
||||
if (g_file_info_get_file_type (source_info) != G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3029,18 +3029,6 @@ ostree_repo_open (OstreeRepo *self,
|
|||
if (!ostree_repo_reload_config (self, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
/* TODO - delete this */
|
||||
if (self->mode == OSTREE_REPO_MODE_ARCHIVE && self->enable_uncompressed_cache)
|
||||
{
|
||||
if (!glnx_shutil_mkdir_p_at (self->repo_dir_fd, "uncompressed-objects-cache", 0755,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
if (!glnx_opendirat (self->repo_dir_fd, "uncompressed-objects-cache", TRUE,
|
||||
&self->uncompressed_objects_dir_fd,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->inited = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
# This should be dynamic now
|
||||
assert_not_has_dir repo/uncompressed-objects-cache
|
||||
|
||||
validate_checkout_basic() {
|
||||
(cd $1;
|
||||
assert_has_file firstfile
|
||||
|
|
|
|||
Loading…
Reference in New Issue