Skip to content

Commit 9b1d727

Browse files
committed
gvfs-helper: create shared object cache if missing
Users should be allowed to delete their shared cache and have it recreated on 'git fetch'. This change makes that happen by creating any leading directories and then creating the directory itself with mkdir(). Signed-off-by: Derrick Stolee <stolee@gmail.com>
1 parent bea18f5 commit 9b1d727

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

gvfs-helper.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,13 +1352,16 @@ static int option_parse_shared_cache_directory(const struct option *opt,
13521352
*/
13531353
strbuf_addbuf(&gvfs_shared_cache_pathname, &buf_arg);
13541354

1355+
/* Attempt to create the directory, in case it doesn't exist. */
1356+
safe_create_leading_directories(the_repository,
1357+
gvfs_shared_cache_pathname.buf);
1358+
mkdir(gvfs_shared_cache_pathname.buf, 0777);
1359+
13551360
odb_add_to_alternates_memory(the_repository->objects, buf_arg.buf);
13561361

13571362
strbuf_release(&buf_arg);
13581363
return 0;
1359-
}
1360-
1361-
else {
1364+
} else {
13621365
/*
13631366
* The requested shared-cache is different from the one
13641367
* we inherited. Replace the inherited value with this
@@ -1371,6 +1374,11 @@ static int option_parse_shared_cache_directory(const struct option *opt,
13711374
strbuf_setlen(&gvfs_shared_cache_pathname, 0);
13721375
strbuf_addbuf(&gvfs_shared_cache_pathname, &buf_arg);
13731376

1377+
/* Attempt to create the directory, in case it doesn't exist. */
1378+
safe_create_leading_directories(the_repository,
1379+
gvfs_shared_cache_pathname.buf);
1380+
mkdir(gvfs_shared_cache_pathname.buf, 0777);
1381+
13741382
odb_add_to_alternates_memory(the_repository->objects, buf_arg.buf);
13751383

13761384
/*

0 commit comments

Comments
 (0)