mirror of
https://github.com/ankitects/anki.git
synced 2026-01-07 02:53:54 -05:00
feat: Expose media file size and filename length constants
This commit is contained in:
parent
3890e12c9e
commit
9fc0b4e260
2 changed files with 26 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ service MediaService {
|
|||
rpc RestoreTrash(generic.Empty) returns (generic.Empty);
|
||||
rpc ExtractStaticMediaFiles(notetypes.NotetypeId)
|
||||
returns (generic.StringList);
|
||||
rpc GetMediaConstants(generic.Empty) returns (MediaConstants);
|
||||
}
|
||||
|
||||
// Implicitly includes any of the above methods that are not listed in the
|
||||
|
|
@ -40,3 +41,12 @@ message AddMediaFileRequest {
|
|||
string desired_name = 1;
|
||||
bytes data = 2;
|
||||
}
|
||||
|
||||
message MediaConstants {
|
||||
// Maximum media file size in bytes (100 MiB)
|
||||
uint64 max_individual_file_size = 1;
|
||||
// Maximum media filename length (client-side)
|
||||
uint32 max_filename_length = 2;
|
||||
// Maximum media filename length (server-side)
|
||||
uint32 max_filename_length_server = 3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use anki_proto::generic;
|
||||
use anki_proto::media::AddMediaFileRequest;
|
||||
use anki_proto::media::CheckMediaResponse;
|
||||
|
|
@ -66,4 +67,17 @@ impl crate::services::MediaService for Collection {
|
|||
|
||||
Ok(files.into_iter().collect::<Vec<_>>().into())
|
||||
}
|
||||
|
||||
fn get_media_constants(&mut self) -> error::Result<anki_proto::media::MediaConstants> {
|
||||
use crate::sync::media::{
|
||||
MAX_INDIVIDUAL_MEDIA_FILE_SIZE, MAX_MEDIA_FILENAME_LENGTH,
|
||||
MAX_MEDIA_FILENAME_LENGTH_SERVER,
|
||||
};
|
||||
|
||||
Ok(anki_proto::media::MediaConstants {
|
||||
max_individual_file_size: MAX_INDIVIDUAL_MEDIA_FILE_SIZE as u64,
|
||||
max_filename_length: MAX_MEDIA_FILENAME_LENGTH as u32,
|
||||
max_filename_length_server: MAX_MEDIA_FILENAME_LENGTH_SERVER as u32,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue