mirror of
https://github.com/ankitects/anki.git
synced 2026-01-12 13:33:55 -05:00
feat: Expose media file size and filename length constants
This commit is contained in:
parent
2d4de33cf3
commit
097701348f
3 changed files with 23 additions and 2 deletions
|
|
@ -255,6 +255,7 @@ Ranjit Odedra <ranjitodedra.dev@gmail.com>
|
|||
Eltaurus <https://github.com/Eltaurus-Lt>
|
||||
jariji
|
||||
Francisco Esteva <fr.esteva@duocuc.cl>
|
||||
Raiyyan <f20241312@pilani.bits-pilani.ac.in>
|
||||
|
||||
********************
|
||||
|
||||
|
|
|
|||
|
|
@ -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,9 @@ message AddMediaFileRequest {
|
|||
string desired_name = 1;
|
||||
bytes data = 2;
|
||||
}
|
||||
|
||||
message MediaConstants {
|
||||
int64 max_individual_media_file_size = 1;
|
||||
int64 max_media_filename_length = 2;
|
||||
int64 max_media_filename_length_server = 3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
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;
|
||||
use anki_proto::media::MediaConstants;
|
||||
use anki_proto::media::TrashMediaFilesRequest;
|
||||
|
||||
use crate::collection::Collection;
|
||||
|
|
@ -12,6 +14,9 @@ use crate::error;
|
|||
use crate::error::OrNotFound;
|
||||
use crate::notes::service::to_i64s;
|
||||
use crate::notetype::NotetypeId;
|
||||
use crate::sync::media::MAX_INDIVIDUAL_MEDIA_FILE_SIZE;
|
||||
use crate::sync::media::MAX_MEDIA_FILENAME_LENGTH;
|
||||
use crate::sync::media::MAX_MEDIA_FILENAME_LENGTH_SERVER;
|
||||
|
||||
impl crate::services::MediaService for Collection {
|
||||
fn check_media(&mut self) -> error::Result<CheckMediaResponse> {
|
||||
|
|
@ -66,4 +71,12 @@ impl crate::services::MediaService for Collection {
|
|||
|
||||
Ok(files.into_iter().collect::<Vec<_>>().into())
|
||||
}
|
||||
|
||||
fn get_media_constants(&mut self) -> error::Result<MediaConstants> {
|
||||
Ok(MediaConstants {
|
||||
max_individual_media_file_size: MAX_INDIVIDUAL_MEDIA_FILE_SIZE as i64,
|
||||
max_media_filename_length: MAX_MEDIA_FILENAME_LENGTH as i64,
|
||||
max_media_filename_length_server: MAX_MEDIA_FILENAME_LENGTH_SERVER as i64,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue