Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“本机存储”删除文件没有后悔药 #5832

Closed
KnIfER opened this issue Jan 6, 2024 · 4 comments
Closed

“本机存储”删除文件没有后悔药 #5832

KnIfER opened this issue Jan 6, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@KnIfER
Copy link

KnIfER commented Jan 6, 2024

Description of the feature / 需求描述

云盘都有回收站功能,本机存储反而直接是永久性删除。希望remove api能添加变量!

我UI都做好了,您瞧:

image

Suggested solution / 实现思路

外挂实现,需要 win32 c++ 编程, 我编了个: https://github.com/appxmod/DeviceSuppressor

cli 调用方式:DeviceSuppressor.exe delete="fullpath"

java 调用方式(魔改ftpserver中的 NativeFtpFile.java):

    /**
     * Delete file.
     */
    public boolean delete() {
        boolean retVal = false;
        if (isRemovable()) {
            Object account = fsView.session.getAttribute("account");
            CMN.debug("delete::account=", account);
            if ((account!=null&&String.valueOf(account).contains("cleaner"))) {
                retVal = file.delete();
            } else {
                // 回收
                try {
                    String ffmpegexe = "C:\\source\\repos\\DeviceSuppressor\\Release\\DeviceSuppressor.exe";
                    Process proc = new ProcessBuilder(ffmpegexe
                            , "delete=" + file.getPath()).start();
                    proc.getOutputStream().write("\nexit\n\n".getBytes(StandardCharsets.UTF_8));
                    boolean[] ret = new boolean[1];
                    BufferedReader errorResult = new BufferedReader(new InputStreamReader(proc.getInputStream()));
                    new Thread(() -> {
                        while (proc.isAlive()) try {
                            String ln = errorResult.readLine();
                            CMN.debug(ln);
                            if (ln.contains("deleted=0")) ret[0] = true;
                        } catch (Exception e) {
                            CMN.Log(e);
                        }
                    }).start();
                    proc.waitFor();
                    retVal = ret[0];
                } catch (Exception e) {
                    CMN.debug(e);
                }
            }
        }
        return retVal;
    }
@KnIfER KnIfER added the enhancement New feature or request label Jan 6, 2024
Copy link

welcome bot commented Jan 6, 2024

Thanks for opening your first issue here! Be sure to follow the issue template!

@IAALAI
Copy link

IAALAI commented Jan 7, 2024

你这个是前端的验证?这种验证不需要对于后端有变动啊。
而且,alist不是基于linux开发的吗?windows的支持是来自于MinGW的

@KnIfER
Copy link
Author

KnIfER commented Jan 8, 2024

你这个是前端的验证?

这个叫 客户端

不需要对于后端有变动啊

alist 驱动并未实现相关api,本机存储默认就是直接删除的。

我就另开ftp外挂,实现回收而不是永久性删除。

alist不是基于linux开发的吗?windows的支持是来自于MinGW

我这是安卓客户端,连着window上的alist,浏览磁盘的内容。。。

附 alist 与 ftp 的浅显比较: #5828

@yqs112358
Copy link

话说在Windows平台下recycle bin path似乎没法工作,直接把文件移动进C:\$Recycle.Bin是不会进入回收站的🥲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants