error checks around performing the resize
this throws on windows and causes undefined mappings on linux
This commit is contained in:
parent
db73c90e34
commit
1780bd097a
@ -24,8 +24,18 @@ struct File2RWMapped : public File2I {
|
|||||||
|
|
||||||
_file_size = std::filesystem::file_size(native_file_path);
|
_file_size = std::filesystem::file_size(native_file_path);
|
||||||
if (file_size >= 0 && _file_size != file_size) {
|
if (file_size >= 0 && _file_size != file_size) {
|
||||||
_file_size = file_size;
|
try {
|
||||||
std::filesystem::resize_file(native_file_path, file_size); // ensure size, usually sparse
|
std::filesystem::resize_file(native_file_path, file_size); // ensure size, usually sparse
|
||||||
|
} catch (...) {
|
||||||
|
std::cerr << "FileRWMapped error: resizing file failed\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_file_size = std::filesystem::file_size(native_file_path);
|
||||||
|
if (_file_size != file_size) {
|
||||||
|
std::cerr << "FileRWMapped error: resizing file failed (size mismatch)\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::error_code err;
|
std::error_code err;
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "./re_announce_systems.hpp"
|
#include "./re_announce_systems.hpp"
|
||||||
#include "./chunk_picker_systems.hpp"
|
#include "./chunk_picker_systems.hpp"
|
||||||
#include "./transfer_stats_systems.hpp"
|
#include "./transfer_stats_systems.hpp"
|
||||||
#include "solanaceae/object_store/object_store.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
@ -185,6 +184,7 @@ File2I* SHA1_NGCFT1::objGetFile2Write(ObjectHandle o) {
|
|||||||
File2I* SHA1_NGCFT1::objGetFile2Read(ObjectHandle o) {
|
File2I* SHA1_NGCFT1::objGetFile2Read(ObjectHandle o) {
|
||||||
auto* file2_comp_ptr = o.try_get<Components::FT1File2>();
|
auto* file2_comp_ptr = o.try_get<Components::FT1File2>();
|
||||||
if (file2_comp_ptr == nullptr || !file2_comp_ptr->file || !file2_comp_ptr->file->can_read || !file2_comp_ptr->file->isGood()) {
|
if (file2_comp_ptr == nullptr || !file2_comp_ptr->file || !file2_comp_ptr->file->can_read || !file2_comp_ptr->file->isGood()) {
|
||||||
|
std::cout << "SHA1_NGCFT1: (re)opening object " << entt::to_integral(entt::to_entity(o.entity())) << " for reading\n";
|
||||||
// (re)request file2 from backend
|
// (re)request file2 from backend
|
||||||
auto new_file = _mfb.file2(o, StorageBackendIFile2::FILE2_READ);
|
auto new_file = _mfb.file2(o, StorageBackendIFile2::FILE2_READ);
|
||||||
if (!new_file || !new_file->can_read || !new_file->isGood()) {
|
if (!new_file || !new_file->can_read || !new_file->isGood()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user