Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/app-lib/src/api/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ pub use self::screenshots::{
pub(crate) use self::shared::{
CONFIG_BUNDLE_FILE_TYPE, CONFIG_DIRECTORY, CONFIG_FILE_EXTENSIONS,
CONFIG_FILE_TYPE, CONFIG_SYNC_ENABLED, MAX_CONFIG_BUNDLE_ENTRIES,
MAX_SHARED_FILES_TOTAL_SIZE, is_shareable_file_path,
is_supported_config_file, read_bounded_config_bundle_entry,
shared_instance_update_data, shared_modpack_files,
is_shareable_file_path, is_supported_config_file,
read_bounded_config_bundle_entry, shared_instance_update_data,
shared_modpack_files,
};
pub use self::shared::{
SharedInstanceExternalFilePreview, SharedInstanceInstallPreview,
Expand Down
7 changes: 5 additions & 2 deletions packages/app-lib/src/api/instance/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ pub(crate) const CONFIG_BUNDLE_FILE_TYPE: &str = "configs";
pub(crate) const CONFIG_FILE_TYPE: &str = "config";
pub(crate) const CONFIG_SYNC_ENABLED: bool = true;
pub(crate) const CONFIG_DIRECTORY: &str = "config";
pub(crate) const MAX_SHARED_FILES: usize = 4096;
pub(crate) const MAX_SHARED_FILES_TOTAL_SIZE: u64 = 500 * 1024 * 1024;
/// Number of shared files in a version, when publishing and downloading.
pub(crate) const MAX_SHARED_FILES: usize = 16384;
/// Total size of a version's shared files when publishing and downloading,
/// matching the backend's per-version external file limit.
pub(crate) const MAX_SHARED_FILES_TOTAL_SIZE: u64 = 2 * 1024 * 1024 * 1024;
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
pub(crate) const MAX_CONFIG_BUNDLE_ENTRIES: usize = 4096;
pub(crate) const MAX_CONFIG_BUNDLE_FILE_SIZE: u64 = 512 * 1024 * 1024;
pub(crate) const MAX_CONFIG_BUNDLE_TOTAL_SIZE: u64 = 512 * 1024 * 1024;
Expand Down
20 changes: 9 additions & 11 deletions packages/app-lib/src/install/shared_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use super::runner::{
use crate::ErrorKind;
use crate::api::instance::{
CONFIG_BUNDLE_FILE_TYPE, CONFIG_DIRECTORY, CONFIG_FILE_TYPE,
CONFIG_SYNC_ENABLED, MAX_CONFIG_BUNDLE_ENTRIES,
MAX_SHARED_FILES_TOTAL_SIZE, is_shareable_file_path,
CONFIG_SYNC_ENABLED, MAX_CONFIG_BUNDLE_ENTRIES, is_shareable_file_path,
is_supported_config_file, read_bounded_config_bundle_entry,
shared_modpack_files,
};
Expand All @@ -40,7 +39,7 @@ use uuid::Uuid;
const DEFAULT_SERVER_ICON: &[u8] = include_bytes!(
"../../../assets/external/illustrations/minecraft_server_icon.png"
);
const MAX_SHARED_INSTANCE_EXTERNAL_FILE_SIZE: u64 = 500 * 1024 * 1024;
const MAX_SHARED_INSTANCE_CONFIG_BUNDLE_SIZE: u64 = 500 * 1024 * 1024;
const MAX_SHARED_INSTANCE_INITIAL_BUFFER_SIZE: u64 = 8 * 1024 * 1024;
const SHARED_INSTANCE_CONTENT_DOWNLOAD_CONCURRENCY: usize = 4;
const SHARED_INSTANCE_FILE_DOWNLOAD_CONCURRENCY: usize = 64;
Expand Down Expand Up @@ -1505,9 +1504,11 @@ async fn install_shared_instance_external_file(

validate_shared_instance_external_file_name(&file.file_name)?;

if file.file_size > MAX_SHARED_INSTANCE_EXTERNAL_FILE_SIZE {
if file.file_type == CONFIG_BUNDLE_FILE_TYPE
&& file.file_size > MAX_SHARED_INSTANCE_CONFIG_BUNDLE_SIZE
{
Comment thread
fetchfern marked this conversation as resolved.
Resolved
bail!(ErrorKind::InputError(format!(
"shared instance external file {} exceeds the maximum size",
"shared instance config bundle {} exceeds the maximum size",
file.file_name
)));
}
Expand Down Expand Up @@ -1598,8 +1599,7 @@ async fn install_shared_instance_external_file(
Ok(())
}

/// Shared files can be up to the version's size limit, so they are streamed to
/// disk rather than held in memory.
/// Shared files are streamed to disk rather than held in memory.
async fn install_shared_instance_file(
writer: &crate::api::instance::InstanceFileWriter,
file: &SharedInstanceExternalFileData,
Expand All @@ -1610,11 +1610,9 @@ async fn install_shared_instance_file(
downloaded.add(file.file_size);
return Ok(());
}
if !is_shareable_file_path(&file.file_name)
|| file.file_size > MAX_SHARED_FILES_TOTAL_SIZE
{
if !is_shareable_file_path(&file.file_name) {
bail!(ErrorKind::InputError(format!(
"shared instance file {} is unsupported or too large",
"shared instance file {} is unsupported",
file.file_name
)));
}
Expand Down