Honor channel permission hints for file moves and directory downloads
This commit is contained in:
1 parent
de99c5fdea
commit
b7635deb8b
3 files changed
+30
-1
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- The channel file browser disables Move when the channel denies rename. Download Folder requires both browsing and downloading permission.
|
||||
|
||||
- Check the dimensions of inline channel images before allocating decoded pixels.
|
||||
|
||||
- Reject zero transfer IDs for pause, resume and cancel before dispatch.
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
## Возврат к разработке на ПК, 2026-11-26
|
||||
|
||||
Windows, база `de99c5f`: файловый браузер учитывает запрет переименования для «Переместить» и запрет просмотра или скачивания для «Скачать папку». Четыре теста модели меню прошли. Проверка отображения разрешений не заменяет живое выполнение mkdir/rename/delete; эти команды остаются открытыми.
|
||||
|
||||
Windows, база `b4e084d`: закрыт `command:file_fetch_image` для классического beta14. Проверены байты и отрисовка PNG в окне Slint, а также отбрасывание устаревших результатов после переподключения. Ограничения размеров проверяются до декодирования растра. Прошли четыре нативных проверки и тест stdio. Стенд остановлен.
|
||||
|
||||
Windows, база `c6cb353`: проверены `file_pause`, `file_resume` и `file_cancel` из панели Slint на классическом beta14. Отмена частично скачанного файла не оставила ни результата, ни временного файла; продолжение второй передачи дало точные 4 МиБ. Прошли живой тест, проверка границ ID через stdio и четыре теста ядра. Стенд остановлен.
|
||||
|
||||
@@ -50,7 +50,16 @@ fn project_browser(target:&Target,channel:u64,path:&str,reply:&Value,mode:Storag
|
||||
}
|
||||
if path!="/"{let up=Target{entity:Entity::File{channel_id:channel,path:parent(path),directory:true},name:"..".into(),..target.clone()};d.entries.insert(0,entry(up.clone(),"..".into(),String::new(),vec![action(&up,Operation::FileBrowse,c)]));}
|
||||
for row in &mut d.entries{
|
||||
if row.title!=".."{row.actions.push(action(&row.target,Operation::FileMove,c));if matches!(row.target.entity,Entity::File{directory:true,..}){row.actions.push(action(&row.target,Operation::FileDownload,c));row.actions.push(action(&row.target,Operation::FileCopyLink,c));}}
|
||||
if row.title!=".."{
|
||||
let mut move_item=action(&row.target,Operation::FileMove,c);
|
||||
if reply["capabilities"]["rename"]==false{move_item.enabled=false;move_item.reason=c.text("admin.denied");}
|
||||
row.actions.push(move_item);
|
||||
if matches!(row.target.entity,Entity::File{directory:true,..}){
|
||||
let mut download=action(&row.target,Operation::FileDownload,c);
|
||||
if reply["capabilities"]["download"]==false||reply["capabilities"]["browse"]==false{download.enabled=false;download.reason=c.text("admin.denied");}
|
||||
row.actions.push(download);row.actions.push(action(&row.target,Operation::FileCopyLink,c));
|
||||
}
|
||||
}
|
||||
for a in &mut row.actions{a.form=None;mode.restrict(channel,a,c);}
|
||||
}
|
||||
Ok(d)
|
||||
@@ -148,6 +157,22 @@ mod tests {
|
||||
assert_eq!(StorageMode::from_server(&Value::Null,Some(&json!({"storage":{"s3":true}}))),mode);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_move_and_folder_download_follow_channel_permissions() {
|
||||
let catalog=Catalog::default();
|
||||
let target=Target{session:Some(SessionKey{connection_id:"c1".into(),session:1,generation:1}),entity:Entity::Channel{id:4},..Target::application()};
|
||||
for (rename,download,browse) in [(false,true,true),(true,false,true),(true,true,false),(true,true,true)] {
|
||||
let reply=json!({"channel_id":4,"path":"/","entries":[{"name":"folder","type":"folder"},{"name":"file","type":"file"}],
|
||||
"capabilities":{"rename":rename,"download":download,"browse":browse}});
|
||||
let panel=project_browser(&target,4,"/",&reply,StorageMode::Legacy,&catalog).unwrap();
|
||||
for row in &panel.entries {
|
||||
let enabled=|op|row.actions.iter().find(|a|a.operation==op).unwrap().enabled;
|
||||
assert_eq!(enabled(Operation::FileMove),rename);
|
||||
assert_eq!(enabled(Operation::FileDownload),download && (row.title!="folder" || browse));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_storage_and_channel_permissions_both_gate_file_actions() {
|
||||
let c=Catalog::default();
|
||||
|
||||
Reference in new issue
Block a user