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