syntax = "proto3";
package files;

option go_package = "./;files";


service File{
    rpc List(FileListReq) returns (FileListResp) {} // 获取当前路径下的文件列表
    rpc Create(CreateReq) returns (CreateResp) {} // 创建文件夹
    rpc Delete(DeleteReq) returns (DeleteResp) {} // 删除文件或文件夹
    rpc Search(searchReq) returns (searchResp) {} // 搜索
    rpc Upload(UploadReq) returns (UploadResp) {} // 文件上传
    rpc TusCreate(TusCreateReq) returns(TusCreateResp) {} // 分块文件上传：创建文件
    rpc TusUpload(TusUploadReq) returns(TusUploadResp) {} // 分块文件上传：上传文件块
} 

message FileListReq{
    string path = 1; // 目标文件夹路径
    string UserSpacePath = 2; // 用户空间的路径
    Sorting sorting = 3;  
}

message Items {
    string path = 1;
    string name = 2;
    int64 size = 3;
    string extension = 4;
    string modified = 5;
    string mode = 6;
    bool isDir = 7;
    bool isSymlink = 8;
    string type = 9;
}

message Sorting {
    string by = 1;
    bool asc = 2;
}

message FileListResp {
    repeated Items items = 1;
    int32 numDirs = 2;
    int32 numFiles = 3;
    Sorting sorting = 4;
    string path = 5;
    string name = 6;
    int64 size = 7;
    string extension = 8;
    string modified = 9;
    string mode = 10;
    bool isDir = 11;
    bool isSymlink = 12;
    string type = 13;
}


message CreateReq{
    string path = 1;
    string userSpacePath = 2;
}

message CreateResp{

}


message DeleteReq{
    string path = 1;
    string userSpacePath = 2;
}

message DeleteResp{

}

message UploadReq{
    string path = 1;
    string userSpacePath = 2;
    bytes content =3;

}

message UploadResp{

}

message searchReq{
    string path = 1;
    string userSpacePath = 2;
    string query = 3;
}

message searchResp{
    
    message Nested {
        bool dir = 1;
        string path = 2;
    }

    repeated Nested items = 1;
}


message TusCreateReq{
    string path = 1;
    string userSpacePath = 2;
    bool override =3 ;
}

message TusCreateResp{
    int64 uploadLength  = 1;
    int64 uploadOffset = 2;
}

message TusUploadReq{
    string path = 1;
    string userSpacePath = 2;
    int64 uploadOffset = 3;
    bytes content = 4;
}

message TusUploadResp{
    int64 uploadOffset = 1;
}