498
499
struct tmp_objdir *objdir;
500
struct transaction_packfile packfile;
501
+ const char *prefix;
502
};
503
504
static int odb_transaction_files_prepare(struct odb_transaction *base)
515
if (!transaction || transaction->objdir)
516
return 0;
517
517
- transaction->objdir = tmp_objdir_create(base->source->odb->repo, "bulk-fsync");
518
+ transaction->objdir = tmp_objdir_create(base->source->odb->repo, transaction->prefix);
519
if (!transaction->objdir)
520
return error(_("unable to create temporary object directory"));
521
1358
int inflight = !!transaction;
1359
1360
if (!inflight)
1360
- odb_transaction_begin_or_die(odb, &transaction);
1361
+ odb_transaction_begin_or_die(odb, &transaction, 0);
1362
ret = odb_transaction_write_object_stream(transaction,
1363
&stream,
1364
xsize_t(st->st_size),
1702
}
1703
1704
int odb_transaction_files_begin(struct odb_source *source,
1704
- struct odb_transaction **out)
1705
+ struct odb_transaction **out,
1706
+ enum odb_transaction_flags flags)
1707
{
1708
struct odb_transaction_files *transaction;
1709
1712
transaction->base.commit = odb_transaction_files_commit;
1713
transaction->base.write_object_stream = odb_transaction_files_write_object_stream;
1714
transaction->base.env = odb_transaction_files_env;
1715
+
1716
+ transaction->prefix = "bulk-fsync";
1717
+ if (flags & ODB_TRANSACTION_RECEIVE) {
1718
+ /*
1719
+ * ODB transactions for git-receive-pack(1) eagerly create a
1720
+ * temporary directory and use a different temporary directory
1721
+ * prefix.
1722
+ *
1723
+ * NEEDSWORK: This transaction flag is only used by the "files"
1724
+ * backend to special case temporary directory set up and
1725
+ * handling. Ideally transaction users should not have to care
1726
+ * though. To avoid this, we could eagerly create the temporary
1727
+ * directory and use the same prefix name for all transactions.
1728
+ */
1729
+ transaction->prefix = "incoming";
1730
+ if (odb_transaction_files_prepare(&transaction->base)) {
1731
+ free(transaction);
1732
+ return -1;
1733
+ }
1734
+ }
1735
+
1736
*out = &transaction->base;
1737
1738
return 0;