Skip to content

Commit

Permalink
for new vlist
Browse files Browse the repository at this point in the history
  • Loading branch information
imzlh committed Jul 11, 2024
1 parent 7840fa8 commit 102f23a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function copy(from: string,to: string) {
}catch(e){
// 尝试创建文件夹
try{
fs.promises.mkdir(to);
await fs.promises.mkdir(to);
var dest_is_dir = true;
}catch(e){
throw new Error('Access failed');
Expand Down Expand Up @@ -121,7 +121,7 @@ async function copy(from: string,to: string) {
throw new Error('Parent Path(' + dest + ') is not a dir');
}catch(e){
try{
fs.promises.mkdir(dest);
await fs.promises.mkdir(dest);
}catch(e){
throw new Error('Copy abort: Create dir failed')
}
Expand Down Expand Up @@ -575,6 +575,22 @@ async function main(h:NginxHTTPRequest){
return h.return(200);
}

// 重命名文件
case 'rename':{
for (let from in request) try{
if(typeof request[from] != 'string' || (from + request[from]).includes('..'))
throw 'Bad Path';

const to = APP_ROOT + '/' + request[from];
from = APP_ROOT + '/' + from;

await fs.promises.rename(from, to);
}catch(e){
return _error(e, 'Rename');
}
return h.return(200);
}

// 移动文件
case 'move':{
if(!(request.from instanceof Array))
Expand Down

0 comments on commit 102f23a

Please sign in to comment.