aliyunpan icon indicating copy to clipboard operation
aliyunpan copied to clipboard

上传文件后,没有调用插件upload_handler.js

Open wxs-dev opened this issue 1 year ago • 5 comments

upload_handler.js插件只写了删除文件的逻辑,文件上传完后没有报错也没有删除文件

function uploadFileFinishCallback(context, params) {
    console.log(params);
    if (params["localFileType"] != "file") {
        // do nothing
        return;
    }
    if (params["uploadResult"] == "success") {
        PluginUtil.LocalFS.deleteFile(params["localFilePath"]);
    }
}

wxs-dev avatar Mar 21 '23 08:03 wxs-dev

你开启debug日志看看,我试了是可以的,文件也被正确删除

[1] 2023-04-02 10:14:23 上传文件成功, 保存到网盘路径: /test/01 Intro.m4a
[1] 2023-04-02 10:14:23 文件上传结果: 成功! 耗时 11秒
[2023-4-2 10:14:06.743] 加载JS脚本成功: upload_handler.js
[2023-4-2 10:14:28.986] JAVASCRIPT: &{LocalFilePath:/Volumes/Downloads/2022-最伟大的作品(m4a)/01 Intro.m4a LocalFileName:01 Intro.m4a LocalFileSize:1479285 LocalFileType:fillFileUpdatedAt:2023-03-25 08:59:16 LocalFileSha1:A52EE0248200509DCE9033DBA772194FF40D952F UploadResult:success DriveId:19519221 DriveFilePath:/test/01 Intro.m4a}
[2023-4-2 10:14:28.986] 插件UploadFileFinishCallback调用成功

tickstep avatar Apr 02 '23 02:04 tickstep

我开启debug日志后,通过docker启动后创建一个test文件,文件妙传后并没有删除 docker启动命令:

docker run -d --name=aliyunsync --restart=always \
-v "/mnt/sda3/unknow:/home/app/data" \
-v /root/app/aliyunpan-sync/sync_drive:/home/app/config/sync_drive \
-v /root/app/aliyunpan-sync/plugin/js/upload_handler.js:/home/app/config/plugin/js/upload_handler.js \
-e TZ="Asia/Shanghai" \
-e ALIYUNPAN_REFRESH_TOKEN="token" \
-e ALIYUNPAN_PAN_DIR="/temp" \
-e ALIYUNPAN_SYNC_MODE="upload" \
-e ALIYUNPAN_LOCAL_DELAY_TIME=60 \
-e ALIYUNPAN_SYNC_LOG=false  \
-e ALIYUNPAN_VERBOSE=1 \
-e ALIYUNPAN_TASK_STEP=sync \
-e ALIYUNPAN_DEVICE_ID=id \
tickstep/aliyunpan-sync:v0.2.7

日志:

[2023-4-5 12:42:03.719] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:03.722] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:03.744] do request url: https://api.aliyundrive.com/v2/user/get
[2023-4-5 12:42:03.936] do request url: https://api.aliyundrive.com/v2/databox/get_personal_info
[2023-4-5 12:42:04.055] do request url: https://api.aliyundrive.com/v2/sbox/get
[2023-4-5 12:42:04.158] do request url: https://api.aliyundrive.com/adrive/v1/user/albums_info
[2023-4-5 12:42:04.242] do request url: https://api.aliyundrive.com/users/v1/users/device/create_session
  名称                   值                        建议值               描述                                                                                          
  cache_size             0B                        1KB ~ 256KB          下载缓存, 如果硬盘占用高或下载速度慢, 请尝试调大此值                                          
  max_download_parallel  0                         1 ~ 20               最大下载并发量,即同时下载文件最大数量                                                        
  max_upload_parallel    0                         1 ~ 20               最大上传并发量,即同时上传文件最大数量                                                        
  max_download_rate      不限制                                         限制单个文件最大下载速度, 0代表不限制                                                         
  max_upload_rate        不限制                                         限制单个文件最大上传速度, 0代表不限制                                                         
  transfer_url_type      0                         1-默认,2-阿里云ECS  上传下载URL类别。除非在阿里云ECS(暂只支持经典网络)服务器中使用,不然请设置1                 
  savedir                /root/Downloads                                下载文件的储存目录                                                                            
  proxy                                                                 设置代理, 支持 http/socks5 代理,例如: http://127.0.0.1:8888 或者 socks5://127.0.0.1:8889     
  local_addrs                                                           设置本地网卡地址, 多个地址用逗号隔开,例如: 127.0.0.1,192.168.100.126                         
  file_record_config     禁用                      1-开启,2-禁用       设置是否开启上传、下载、同步文件的结果记录,开启后会把结果记录到CSV文件方便后期查看           
  device_id              马赛克                       客户端ID,用于标识登录客户端,阿里单个账号最多允许10个客户端同时在线。修改后需要重启应用生效  
保存配置成功!
[2023-4-5 12:42:04.519] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:04.522] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:04.544] do request url: https://api.aliyundrive.com/v2/user/get
[2023-4-5 12:42:04.736] do request url: https://api.aliyundrive.com/v2/databox/get_personal_info
[2023-4-5 12:42:04.841] do request url: https://api.aliyundrive.com/v2/sbox/get
[2023-4-5 12:42:04.937] do request url: https://api.aliyundrive.com/adrive/v1/user/albums_info
[2023-4-5 12:42:05.025] do request url: https://api.aliyundrive.com/users/v1/users/device/create_session
[2023-4-5 12:42:05.163] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:05.164] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
启动同步备份进程
备份配置文件:/home/app/config/sync_drive/sync_drive_config.json
链接类型:默认链接
下载并发:2
上传并发:2
下载分片大小:1.00MB
上传分片大小:10.00MB
[2023-4-5 12:42:05.165] do request url: https://api.aliyundrive.com/v2/file/list
[2023-4-5 12:42:05.275] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:05.279] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:05.280] 加载JS脚本成功: upload_handler.js
[2023-4-5 12:42:05.280] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:05.281] do request url: https://api.aliyundrive.com/v2/file/list
[2023-4-5 12:42:05.284] use config dir from ALIYUNPAN_CONFIG_DIR env:  /home/app/config
[2023-4-5 12:42:05.286] 加载JS脚本成功: upload_handler.js
启动同步任务
任务: 阿里云盘备份(5b2d7c10-e927-4e72-8f9d-5abb3bb04814)
同步模式: 备份本地文件(只上传)
本地目录: /home/app/data
云盘目录: /temp
[2023-4-5 12:42:05.310] file is the same, no need to update file:  /home/app/data/test.txt
[2023-4-5 12:42:05.321] file is the same, no need to update file:  /home/app/data/test.txt
[2023-4-5 12:42:05.326] do scan local file process at  2023-04-05 12:42:05
[2023-4-5 12:42:05.333] update local file to db:  {"fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:30:45","updatedAt":"2023-04-05 12:30:45","fileExtension":".txt","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/home/app/data/test.txt","scanTimeAt":"2023-04-05 12:42:05","scanStatus":"normal"}
本命令不会退出,程序正在以Docker的方式运行。如需退出请借助Docker提供的方式。
[2023-4-5 12:42:05.596] do scan pan file process at  2023-04-05 12:42:05
[2023-4-5 12:42:05.596] do request url: https://api.aliyundrive.com/v2/file/list
[2023-4-5 12:42:08.323] file is the same, no need to update file:  /home/app/data/test.txt
[2023-4-5 12:42:08.814] file is the same, no need to update file:  /home/app/data/test.txt
[2023-4-5 12:42:10.712] delete discard pan file from DB:  {"driveId":"5591854","domainId":"bj29","fileId":"642cfb7e5cf49eb806d44f569f803eebb6582163","fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:39:26","updatedAt":"2023-04-05 12:40:23","fileExtension":"txt","uploadId":"rapid-e3701e4f-9134-45f1-ad5b-2d24f4f9081d","parentFileId":"642cf9409e0c926c101247f8b2a22e20a5e4bdea","crc64Hash":"0","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/temp/test.txt","category":"doc","scanTimeAt":"2023-04-05 12:40:27","scanStatus":"normal"}
[2023-4-5 12:42:10.712] notify pan folder modify, need to do file action task
[2023-4-5 12:42:35.855] do scan local file process at  2023-04-05 12:42:35
[2023-4-5 12:42:35.856] update local file to db:  {"fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:30:45","updatedAt":"2023-04-05 12:30:45","fileExtension":".txt","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/home/app/data/test.txt","scanTimeAt":"2023-04-05 12:42:35","scanStatus":"normal"}
[2023-4-5 12:43:06.378] do scan local file process at  2023-04-05 12:43:06
[2023-4-5 12:43:06.379] update local file to db:  {"fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:30:45","updatedAt":"2023-04-05 12:30:45","fileExtension":".txt","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/home/app/data/test.txt","scanTimeAt":"2023-04-05 12:43:06","scanStatus":"normal"}
[2023-4-5 12:43:17.083] file action task: {"action":"upload","status":"create","localFile":{"fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:30:45","updatedAt":"2023-04-05 12:30:45","fileExtension":".txt","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/home/app/data/test.txt","scanTimeAt":"2023-04-05 12:42:05","scanStatus":"normal"},"panFile":null,"localFolderPath":"/home/app/data","panFolderPath":"/temp","statusUpdateTime":"","driveId":"5591854","useInternalUrl":false,"downloadRange":null,"downloadBlockSize":1048576,"uploadRange":null,"uploadEntity":null,"uploadPartSeq":0,"uploadBlockSize":10485760}
[2023-4-5 12:43:17.085] do request url: https://api.aliyundrive.com/v2/file/list
[2023-4-5 12:43:17.337] do request url: https://api.aliyundrive.com/v2/file/list
[2023-4-5 12:43:22.434] do request url: https://api.aliyundrive.com/adrive/v2/file/createWithFolders
[2023-4-5 12:43:26.317] 秒传成功, 保存到网盘路径: /temp/test.txt
[2023-4-5 12:43:30.923] do request url: https://api.aliyundrive.com/v2/file/get
[2023-4-5 12:43:36.905] do scan local file process at  2023-04-05 12:43:36
[2023-4-5 12:43:36.906] update local file to db:  {"fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:30:45","updatedAt":"2023-04-05 12:30:45","fileExtension":".txt","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/home/app/data/test.txt","scanTimeAt":"2023-04-05 12:43:36","scanStatus":"normal"}
[2023-4-5 12:44:07.435] do scan local file process at  2023-04-05 12:44:07
[2023-4-5 12:44:07.436] update local file to db:  {"fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:30:45","updatedAt":"2023-04-05 12:30:45","fileExtension":".txt","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/home/app/data/test.txt","scanTimeAt":"2023-04-05 12:44:07","scanStatus":"normal"}
[2023-4-5 12:44:10.789] do scan pan file process at  2023-04-05 12:44:10
[2023-4-5 12:44:10.789] do request url: https://api.aliyundrive.com/v2/file/list
[2023-4-5 12:44:10.933] update pan file to db:  {"driveId":"5591854","domainId":"bj29","fileId":"642cfc6a1339e2d44c6446b8a8b66a3c0890a98a","fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:43:22","updatedAt":"2023-04-05 12:43:22","fileExtension":"txt","uploadId":"rapid-7146f661-1cb8-4213-af16-b5dd7cd613f7","parentFileId":"642cf9409e0c926c101247f8b2a22e20a5e4bdea","crc64Hash":"0","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/temp/test.txt","category":"doc","scanTimeAt":"2023-04-05 12:44:10","scanStatus":"normal"}
[2023-4-5 12:44:37.969] do scan local file process at  2023-04-05 12:44:37
[2023-4-5 12:44:37.972] update local file to db:  {"fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:30:45","updatedAt":"2023-04-05 12:30:45","fileExtension":".txt","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/home/app/data/test.txt","scanTimeAt":"2023-04-05 12:44:37","scanStatus":"normal"}
[2023-4-5 12:45:08.511] do scan local file process at  2023-04-05 12:45:08
[2023-4-5 12:45:08.514] update local file to db:  {"fileName":"test.txt","fileSize":0,"fileType":"file","createdAt":"2023-04-05 12:30:45","updatedAt":"2023-04-05 12:30:45","fileExtension":".txt","sha1Hash":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","path":"/home/app/data/test.txt","scanTimeAt":"2023-04-05 12:45:08","scanStatus":"normal"}

      

wxs-dev avatar Apr 05 '23 04:04 wxs-dev

你用的是同步功能,那得用这个sync_handler.js

function syncFileFinishCallback(context, params) {
	...代码逻辑写这里...
}

tickstep avatar Apr 07 '23 13:04 tickstep

你用的是同步功能,那得用这个sync_handler.js

function syncFileFinishCallback(context, params) {
	...代码逻辑写这里...
}

我按你的方法成功加载sync_handler.js后,上传文件后还是没有删除文件,我需要提供其他什么日志给您吗?

wxs-dev avatar Apr 15 '23 10:04 wxs-dev

感觉是docker 映射有问题,自己没创建sync_handler.js的情况 第一次启动后,程序自动创建的是sync_handler.js 是个文件夹不是脚本文件

GeekWorkCode avatar Nov 24 '23 12:11 GeekWorkCode