mirror of https://github.com/aria2/aria2
MacOS: Allocate once (apfs compat)
parent
d508e41198
commit
992944257c
|
@ -525,24 +525,20 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
|
||||||
fileStrerror(errNum).c_str()));
|
fileStrerror(errNum).c_str()));
|
||||||
}
|
}
|
||||||
#elif defined(__APPLE__) && defined(__MACH__)
|
#elif defined(__APPLE__) && defined(__MACH__)
|
||||||
auto toalloc = offset + length - size();
|
const auto toalloc = offset + length - size();
|
||||||
while (toalloc > 0) {
|
fstore_t fstore = {
|
||||||
fstore_t fstore = {
|
F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE,
|
||||||
F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, 0,
|
0, toalloc, 0};
|
||||||
// Allocate in 1GB chunks or else some OSX versions may choke.
|
if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) {
|
||||||
std::min(toalloc, (int64_t)1 << 30), 0};
|
// Retry non-contig.
|
||||||
|
fstore.fst_flags = F_ALLOCATEALL;
|
||||||
if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) {
|
if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) {
|
||||||
// Retry non-contig.
|
int err = errno;
|
||||||
fstore.fst_flags = F_ALLOCATEALL;
|
throw DL_ABORT_EX3(
|
||||||
if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) {
|
err, fmt("fcntl(F_PREALLOCATE) of %" PRId64 " failed. cause: %s",
|
||||||
int err = errno;
|
fstore.fst_length, util::safeStrerror(err).c_str()),
|
||||||
throw DL_ABORT_EX3(
|
error_code::FILE_IO_ERROR);
|
||||||
err, fmt("fcntl(F_PREALLOCATE) of %" PRId64 " failed. cause: %s",
|
|
||||||
fstore.fst_length, util::safeStrerror(err).c_str()),
|
|
||||||
error_code::FILE_IO_ERROR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
toalloc -= fstore.fst_bytesalloc;
|
|
||||||
}
|
}
|
||||||
// This forces the allocation on disk.
|
// This forces the allocation on disk.
|
||||||
ftruncate(fd_, offset + length);
|
ftruncate(fd_, offset + length);
|
||||||
|
|
Loading…
Reference in New Issue