Skip to content

Commit

Permalink
0.32.12a5. Client Put AsTask 修复
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-cq committed Mar 23, 2024
1 parent 3bd7ecd commit 87b06c5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
17 changes: 16 additions & 1 deletion alist_sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"SearchItem",
"Me",
"Task",
"ListTask",
"AsTask",
"Resp",
"HashInfo",
"NoneType",
Expand Down Expand Up @@ -57,7 +59,13 @@
]
TaskStateModify = Literal[0, 1, 2, 3, 4, 5, 6, 7]
TaskStatusModify = Literal[
"", "waiting", "running", "success", "failed", "getting src object"
"",
"waiting",
"running",
"success",
"failed",
"getting src object",
"uploading",
]

OrderDirectionModify = Literal["", "asc", "desc"]
Expand Down Expand Up @@ -175,6 +183,12 @@ class Task(_BaseModel):
error: str # 错误信息


class AsTask(_BaseModel):
"""/api/fs/put .headers"""

task: Task


class ListTask(_BaseModel):
tasks: list[Task]

Expand Down Expand Up @@ -267,5 +281,6 @@ class Resp(_BaseModel):
| RawItem
| ListTask
| list[Task]
| AsTask
| ID
)
3 changes: 2 additions & 1 deletion tests/models_simple/Resps.json
Original file line number Diff line number Diff line change
Expand Up @@ -851,5 +851,6 @@
]
}
}
]
],
["/api/fs/put", "AsTask", {"code":200,"message":"success","data":{"task":{"id":"GWoiexFvPJmJAWwnG0I71","name":"upload Python3810.zip to [/alist-sync](/)","state":0,"status":"uploading","progress":0,"error":""}}} ]
]
11 changes: 11 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ def test_upload_put(self):
assert res.code == 200
assert alist_data_path.exists()

def test_upload_put_as_task(self):
alist_full_name = "/local/upload_file_form_data_task"
alist_data_path = DATA_DIR.joinpath("upload_file_form_data_task")

res = self.run(
self.client.upload_file_put, __file__, alist_full_name, as_task=True
)
assert res.code == 200
time.sleep(2)
assert alist_data_path.exists()

def test_list_dir(self):
DATA_DIR.joinpath("test_list_dir_dir").mkdir()
DATA_DIR.joinpath("test_list_dir_file").write_text("test")
Expand Down

0 comments on commit 87b06c5

Please sign in to comment.