mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-07 01:52:14 +02:00
Fixed reinitialization
This commit is contained in:
parent
01c7f3242c
commit
4e5981488e
@ -508,7 +508,9 @@ namespace sts::ncm::impl {
|
|||||||
Unmount(entry->mount_point);
|
Unmount(entry->mount_point);
|
||||||
};
|
};
|
||||||
|
|
||||||
R_TRY(EnsureDirectoryRecursively(entry->mount_point));
|
D_LOG("storage id: 0x%x\n", storage_id);
|
||||||
|
D_LOG("creating %s\n", entry->meta_path);
|
||||||
|
R_TRY(EnsureDirectoryRecursively(entry->meta_path));
|
||||||
R_TRY(fsdevCommitDevice(entry->mount_point));
|
R_TRY(fsdevCommitDevice(entry->mount_point));
|
||||||
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
@ -517,6 +519,8 @@ namespace sts::ncm::impl {
|
|||||||
Result VerifyContentMetaDatabase(StorageId storage_id) {
|
Result VerifyContentMetaDatabase(StorageId storage_id) {
|
||||||
std::scoped_lock<HosMutex> lk(g_mutex);
|
std::scoped_lock<HosMutex> lk(g_mutex);
|
||||||
|
|
||||||
|
D_LOG("storage id: 0x%x\n", storage_id);
|
||||||
|
|
||||||
if (storage_id == StorageId::GameCard) {
|
if (storage_id == StorageId::GameCard) {
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
@ -538,16 +542,19 @@ namespace sts::ncm::impl {
|
|||||||
mounted_save_data = true;
|
mounted_save_data = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ON_SCOPE_EXIT {
|
||||||
|
if (mounted_save_data) {
|
||||||
|
Unmount(entry->mount_point);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bool has_meta_path = false;
|
bool has_meta_path = false;
|
||||||
R_TRY(HasDirectory(&has_meta_path, entry->meta_path));
|
R_TRY(HasDirectory(&has_meta_path, entry->meta_path));
|
||||||
if (!has_meta_path) {
|
if (!has_meta_path) {
|
||||||
|
D_LOG("Meta path %s not found\n", entry->meta_path);
|
||||||
return ResultNcmInvalidContentMetaDatabase;
|
return ResultNcmInvalidContentMetaDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mounted_save_data) {
|
|
||||||
Unmount(entry->mount_point);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,8 +664,12 @@ namespace sts::ncm::impl {
|
|||||||
if (storage_id != StorageId::GameCard) {
|
if (storage_id != StorageId::GameCard) {
|
||||||
R_TRY(MountSystemSaveData(entry->mount_point, entry->save_meta.space_id, entry->save_meta.id));
|
R_TRY(MountSystemSaveData(entry->mount_point, entry->save_meta.space_id, entry->save_meta.id));
|
||||||
auto mount_guard = SCOPE_GUARD { Unmount(entry->mount_point); };
|
auto mount_guard = SCOPE_GUARD { Unmount(entry->mount_point); };
|
||||||
|
D_LOG("storage_id 0x%x\n", storage_id);
|
||||||
|
D_LOG("init\n");
|
||||||
R_TRY(entry->kvs->Initialize(entry->meta_path, entry->max_content_metas));
|
R_TRY(entry->kvs->Initialize(entry->meta_path, entry->max_content_metas));
|
||||||
|
D_LOG("load\n");
|
||||||
R_TRY(entry->kvs->Load());
|
R_TRY(entry->kvs->Load());
|
||||||
|
D_LOG("loaded\n");
|
||||||
|
|
||||||
auto content_meta_database = std::make_shared<ContentMetaDatabaseInterface>(&*entry->kvs, entry->mount_point);
|
auto content_meta_database = std::make_shared<ContentMetaDatabaseInterface>(&*entry->kvs, entry->mount_point);
|
||||||
entry->content_meta_database = std::move(content_meta_database);
|
entry->content_meta_database = std::move(content_meta_database);
|
||||||
|
@ -170,10 +170,18 @@ namespace sts::ncm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result EnsureDirectoryRecursively(const char* dir_path) {
|
Result EnsureDirectoryRecursively(const char* dir_path) {
|
||||||
return EnsureRecursively(dir_path, true);
|
R_TRY(EnsureRecursively(dir_path));
|
||||||
|
if (mkdir(dir_path, S_IRWXU) == -1) {
|
||||||
|
R_TRY_CATCH(fsdevGetLastResult()) {
|
||||||
|
R_CATCH(ResultFsPathAlreadyExists) {
|
||||||
|
/* If the path already exists, that's okay. Anything else is an error. */
|
||||||
|
}
|
||||||
|
} R_END_TRY_CATCH;
|
||||||
|
}
|
||||||
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result EnsureRecursively(const char* path, bool is_dir) {
|
Result EnsureRecursively(const char* path) {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return ResultFsNullptrArgument;
|
return ResultFsNullptrArgument;
|
||||||
}
|
}
|
||||||
@ -201,6 +209,14 @@ namespace sts::ncm {
|
|||||||
working_path_buf[i + 1] = '/';
|
working_path_buf[i + 1] = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mkdir(working_path_buf + 1, S_IRWXU) == -1) {
|
||||||
|
R_TRY_CATCH(fsdevGetLastResult()) {
|
||||||
|
R_CATCH(ResultFsPathAlreadyExists) {
|
||||||
|
/* If the path already exists, that's okay. Anything else is an error. */
|
||||||
|
}
|
||||||
|
} R_END_TRY_CATCH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ResultNcmAllocationFailed;
|
return ResultNcmAllocationFailed;
|
||||||
@ -210,7 +226,7 @@ namespace sts::ncm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result EnsureParentDirectoryRecursively(const char* path) {
|
Result EnsureParentDirectoryRecursively(const char* path) {
|
||||||
return EnsureRecursively(path, false);
|
return EnsureRecursively(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetGameCardHandle(FsGameCardHandle* out_handle) {
|
Result GetGameCardHandle(FsGameCardHandle* out_handle) {
|
||||||
|
@ -34,7 +34,7 @@ namespace sts::ncm {
|
|||||||
Result EnsureContentAndPlaceHolderRoot(const char* root_path);
|
Result EnsureContentAndPlaceHolderRoot(const char* root_path);
|
||||||
|
|
||||||
Result EnsureDirectoryRecursively(const char* dir_path);
|
Result EnsureDirectoryRecursively(const char* dir_path);
|
||||||
Result EnsureRecursively(const char* path, bool is_dir);
|
Result EnsureRecursively(const char* path);
|
||||||
/* Create all parent directories for a file path */
|
/* Create all parent directories for a file path */
|
||||||
Result EnsureParentDirectoryRecursively(const char* path);
|
Result EnsureParentDirectoryRecursively(const char* path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user