File deletion method and device for nas disk

By creating a recycle bin on the NAS disk and renaming the path, the problem of NAS disk files being unable to be restored after being deleted is solved, and a file deletion method with stability and data security is achieved.

CN116400861BActive Publication Date: 2025-10-21ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310361825.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-30
Publication Date
2025-10-21
Estimated Expiration
2043-03-30

AI Technical Summary

Technical Problem

NAS disks lack a separate recycle bin when files are deleted, making files unrecoverable and leading to system malfunctions and data leaks.

Method used

A recycle bin is created on the NAS disk, and the target file is placed in the recycle bin of the NAS disk through the path renaming mechanism. At the same time, a corresponding path is built on the system disk to maintain consistency, and the MiniFilter framework or Hooking technology is used to monitor and process deletion instructions.

Benefits of technology

It achieves stable deletion of NAS disk files, avoids system anomalies, ensures data migration and security, and prevents data leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116400861B_ABST
    Figure CN116400861B_ABST
Patent Text Reader

Abstract

The application provides a file deletion method and device of a NAS disk, applied to a NAS disk and a system disk, comprising: receiving a first instruction for a target file in the NAS disk; judging whether the first instruction corresponds to a deletion operation of the target file, wherein if the first instruction corresponds to the deletion operation of the target file, a first path corresponding to the target file in the system disk is obtained; a deletion destination path of the first path and a parent directory path of the deletion destination path are obtained, the deletion destination path corresponds to the deletion operation, and it is judged whether the parent directory path of the deletion destination path is a recycle bin path of the system disk, wherein if the parent directory path of the deletion destination path is the recycle bin path of the system disk, the parent directory path of the first path is modified to the parent directory path of the deletion destination path, and the target file in the NAS disk is put into the recycle bin of the NAS disk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud storage technology, and in particular to a method and device for deleting files from a NAS disk. Background Art

[0002] With the growing demand for external computer storage devices, NAS (Network-attached Storage) disks have become a common external storage device. When NAS disks are mounted, the lack of a dedicated Recycle Bin means that deleted files on the NAS disk go directly to the system Recycle Bin and cannot be recovered. Furthermore, when user configuration management projects use NAS disks as data storage devices, the lack of a dedicated Recycle Bin can lead to inconsistent deletion behavior between files on the NAS disk and those on the system disk, causing system anomalies, preventing user data migration, and posing the risk of data leakage. Summary of the Invention

[0003] The embodiments of the present application provide a method and apparatus for deleting files on a NAS disk to solve the above-mentioned problem.

[0004] In a first aspect, the present application provides a file deletion method for a NAS disk, which is applied to a NAS disk and a system disk, comprising: receiving a first instruction for a target file in the NAS disk; determining whether the first instruction corresponds to a deletion operation on the target file, wherein, if the first instruction corresponds to a deletion operation on the target file, obtaining a first path in the system disk corresponding to the target file; obtaining a deletion destination path of the first path and a parent directory path of the deletion destination path, wherein the deletion destination path corresponds to the deletion operation, and determining whether the parent directory path of the deletion destination path is a recycle bin path of the system disk, wherein, if the parent directory path of the deletion destination path is a recycle bin path of the system disk, modifying the parent directory path of the first path to the parent directory path of the deletion destination path, and placing the target file in the NAS disk into the recycle bin of the NAS disk.

[0005] In a second aspect, an embodiment of the present application provides a file deletion device on a NAS disk, the device receiving a first instruction for a target file in the NAS disk, the device including: a path acquisition module, configured to obtain a first path in the system disk corresponding to the target file if the first instruction corresponds to a deletion operation on the target file, and obtain a deletion destination path of the first path and a parent directory path of the deletion destination path, the deletion destination path corresponding to the deletion operation; a judgment module, configured to determine whether the first instruction corresponds to a deletion operation on the target file, and determine whether the parent directory path of the deletion destination path is a recycle bin path of the system disk; a deletion module, configured to modify the parent directory path of the first path to the parent directory path of the deletion destination path if the parent directory path of the deletion destination path is a recycle bin path of the system disk, and place the target file in the NAS disk into the recycle bin of the NAS disk.

[0006] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements any of the methods described above.

[0007] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements any of the above methods when executing the computer program.

[0008] This application has the following advantages:

[0009] According to the embodiments of the present application, a recycle bin can be established on a NAS disk, and file deletion logic corresponding to the recycle bin can be created and configured. First, the path renaming mechanism in the embodiments of the present application can effectively handle cross-volume deletion issues, preventing system anomalies and improving stability. Second, by recording and matching the thread ID and path hash value of the deletion operation, the accuracy of the deletion operation is guaranteed. Furthermore, the method can ensure that user data on the NAS disk can be migrated with the user account without data leakage. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the following is a brief introduction to the drawings required for describing the embodiments. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be derived from these drawings without inventive effort. These drawings only depict some implementation methods of this application and should not be considered as limiting the scope of this application.

[0011] Figure 1 A flowchart of a method for deleting files from a NAS disk provided in an embodiment of the present application;

[0012] Figure 2 A schematic diagram of a file deletion operation on a NAS disk provided in an embodiment of the present application;

[0013] Figure 3 A schematic diagram of another method for deleting files from a NAS disk provided in an embodiment of the present application; and

[0014] Figure 4 A schematic diagram of the structure of a file deletion device for a NAS disk provided in an embodiment of the present application. DETAILED DESCRIPTION

[0015] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0016] The following describes some embodiments of the present application in detail with reference to the accompanying drawings. The following embodiments and their features may be combined, provided they do not conflict with each other. The steps of the methods described in the embodiments may be interchanged, as long as they achieve the purpose of deleting NAS disk files achieved by the methods provided in the embodiments of the present application.

[0017] The present application provides a method for deleting files on a NAS disk. The file deletion method is applied to NAS (Network Attached Storage) disks and system disks. NAS is defined as a special dedicated data storage server that includes storage devices (such as disk arrays, CD / DVD drives, tape drives, or removable storage media) and embedded system software, which can provide cross-platform file sharing functions. NAS connects storage devices to an existing network to provide data and file services. A NAS storage server generally consists of several parts, such as hardware, an operating system, and a file system thereon.

[0018] In some embodiments, unlike a shared disk accessed through a network connection (such as a server disk, a NAS disk, or a shared disk of another computer on the network) or a removable disk connected through an external connection of the computer but which can be plugged in and out at will (such as a mobile hard disk), the system disk can be a disk installed on the same computer motherboard that cannot be plugged in or moved at will (such as a hard disk).

[0019] Figure 1 This is a flowchart of a method 100 for deleting files on a NAS disk provided in an embodiment of the present application. The method 100 includes the following steps S101 to S107: in step S101, receiving a first instruction for a target file in the NAS disk; in step S102, determining whether the first instruction corresponds to a delete operation on the target file, wherein if the first instruction corresponds to a delete operation on the target file, proceeding to step S103; in step S103, obtaining a first path in the system disk corresponding to the target file; in step S104, obtaining a deletion destination path of the first path and a parent directory path of the deletion destination path, wherein the deletion destination path corresponds to the deletion operation; in step S105, determining whether the parent directory path of the deletion destination path is a recycle bin path of the system disk, wherein if the parent directory path of the deletion destination path is a recycle bin path of the system disk, proceeding to step S106; in step S106, modifying the parent directory path of the first path to the parent directory path of the deletion destination path; and in step S107, placing the target file in the NAS disk into the recycle bin of the NAS disk.

[0020] The following will describe steps S101 to S107 respectively.

[0021] In step S101 , a first instruction for a target file in the NAS disk is received.

[0022] The NAS disk contains multiple user file system directories, also known as home directories, stored in the User directory on the NAS disk. Each home directory contains a file system directory for the files of the user corresponding to that home directory. Files created by a user on the NAS disk are stored in that user's home directory on the NAS disk. Each user can only access files within the home directory associated with that user.

[0023] In some embodiments, the first instruction can be a delete instruction that the user inputs into the operating system through a graphical interface using an external input device, for example, the user right-clicks the target file with a mouse and selects the "Delete" option in the displayed menu, or the user uses the keyboard to enter and run a delete instruction for the target file in a command line interface. The target file can be, for example, a file that the user wants to operate on, for example, the target file can be a file that the user wants to delete. It should be noted that the target file can also be a folder or directory. In the following, the "delete instruction" will be used as an example of the first instruction.

[0024] The above is step S101, and the next step is step S102.

[0025] In step S102, it is determined whether the first instruction corresponds to a deletion operation on the target file.

[0026] In some embodiments, the determination of whether the first instruction corresponds to a delete operation on the target file may include: executing a plurality of predetermined operations on the target file in sequence with the delete permission, wherein if the plurality of predetermined operations include a pre-delete operation and a pre-undo delete operation, then the first instruction corresponds to the delete operation on the target file. For example, a pre-delete operation may be executed on the target file using the delete permission, and after the pre-delete operation, a pre-undo operation may be executed. The pre-delete operation may be to modify the parent directory path of the target file to the recycle bin path of the corresponding disk. The pre-undo operation may be to modify the parent directory path of the target file from the recycle bin path to the original parent directory path.

[0027] If the pre-deletion operation is successfully executed, it can be determined that the system has deletion permission for the target file, that is, the first instruction corresponds to the deletion operation of the target file. The system then initiates a pre-undelete operation on the target file to ensure that the file storage status has not been changed.

[0028] In some embodiments, after the system performs the pre-undelete operation on the target file, step S102 further includes recording a thread ID and a path hash value of the pre-delete operation. The pre-delete operation thread ID is used to identify the current pre-delete operation thread. The path hash value is used to identify the path of the currently opened target file.

[0029] In some embodiments, while recording the thread ID and path hash value of the pre-deletion operation, the file deletion method 100 may further include: recording the session ID of the pre-deletion operation.

[0030] It should be understood that although the embodiments of this specification indicate that the target file is stored on a NAS disk in step S101, the target files targeted by the embodiments of this application are not limited to being stored on NAS disks. For example, in some possible embodiments, the target file opened in step S101 may also be located on a system disk. In this case, the target file's path hash value can be used to confirm that the disk where the target file is located is a system disk. Deleting the target file on the system disk can be performed by renaming the target file's parent directory path to the system disk's Recycle Bin path.

[0031] In some embodiments, when deleting a target file located on a different disk, the system first determines which disk the target file is located on. If the target file is determined to be on the system disk, the subsequent deletion operation is performed on the system disk; if the target file is determined to be on a NAS disk, the subsequent deletion operation is performed on the NAS disk. Throughout this specification, unless otherwise specified, "target file" refers to the target file on the NAS disk. In some embodiments, this determination logic can be implemented using a pre-defined MiniFilter file filtering framework, which will be further explained later in this specification.

[0032] The above is step S102, and then proceed to step S103.

[0033] In step S103, a first path in the system disk corresponding to the target file is obtained.

[0034] In some embodiments, the target file is located on a NAS disk, and the system disk does not contain the target file. To delete the target file on the NAS disk, a directory structure corresponding to the target file must first be constructed on the system disk. For example, if the target file is located in the User\A directory on the NAS disk, a directory A is constructed in the root directory of the system disk's C drive, resulting in a C:\A directory. In this embodiment, the first path may be C:\A\filename, where filename may be the file name of the target file.

[0035] In some embodiments, between step S102 and step S103, the file deletion method 100 may further include: opening the target file with deletion permission; and determining whether a session ID of the operation of opening the target file matches the recorded session ID of the pre-deletion operation.

[0036] In some embodiments, between step S102 and step S103, the file deletion method 100 may further include: opening the target file with deletion permission, and determining whether the thread ID and path hash value of the target file opening operation correspond to the thread ID and path hash value of the pre-deletion operation recorded above, wherein if the thread ID and path hash value of the target file opening operation respectively match the thread ID and path hash value of the pre-deletion operation recorded above, then obtaining the first path. By determining whether the thread ID and path hash value of the target file opening operation respectively match the thread ID and path hash value of the pre-deletion operation, confusion of file deletion operations on different threads can be avoided, thereby improving the accuracy of multiple deletion operations in the system.

[0037] The above is step S103, and then proceed to step S104.

[0038] In step S104, a deletion destination path of the first path and a parent directory path of the deletion destination path are acquired, wherein the deletion destination path corresponds to the deletion operation.

[0039] In some embodiments, the deletion destination path of the first path can be a path of a recycle bin: the recycle bin receives the file corresponding to the deleted first path. In the embodiment provided in the specification of this application, the deletion operation of the target file is actually implemented by renaming the target file, such as renaming the path of the file with the path C:\filename to C:\$Recycle.Bin\s\filename, where s is the SID used to mark a unique OBJECT (such as a user or group), thereby deleting the file to the system recycle bin. It should be noted that the target file on the NAS disk does not exist on the system disk, and the first path corresponding to the target file opened on the system disk does not correspond to a file that actually exists on the system disk, but only represents the path of such a file. In this embodiment, the first path is C:\filename; the deletion destination path of the first path is: C:\$Recycle.Bin\s\filename; the parent directory path of the deletion destination path is: C:\$Recycle.Bin.

[0040] The above is step S104, and then proceed to step S105.

[0041] In step S105 , it is determined whether the parent directory path of the deletion destination path is a recycle bin path of the system disk.

[0042] In some embodiments, since the first path constructed in step S103 is located on the system disk, the deletion destination path obtained based on the first path is also located on the system disk. The purpose of steps S104 and S105 is that, since the operating logic of common computer operating systems (such as Windows 10) requires that when deleting a file, the file to be deleted must be located on the same disk as the Recycle Bin, that is, the file to be deleted must be renamed to the Recycle Bin on the disk where the file is located.

[0043] In the embodiment provided herein, when deleting a file on a NAS disk, a corresponding deletion operation must also be performed on the corresponding file (or constructed path) on the system disk, thereby ensuring that file operations on both the NAS disk and the system disk are consistent. Furthermore, to make the operation logic more unified and simple, the Recycle Bin used when deleting a file is the Recycle Bin on the system disk. Therefore, for a target file on the NAS disk, a first path on the system disk corresponding to the target file must be constructed, and then the parent directory path of the deletion target path is obtained based on the first path. Since the parent directory path of the deletion target path and the system disk Recycle Bin are both located on the system disk, while the target file on the NAS disk is being deleted, the path of the first path on the system disk corresponding to the target file on the NAS disk can also be changed (i.e., changed to the Recycle Bin path on the system disk), thereby ensuring that file operations on both the NAS disk and the system disk are consistent.

[0044] If the parent directory path of the deletion destination path is the recycle bin path of the system disk, proceed to step S106 and step S107.

[0045] In step S106, the parent directory path of the first path is modified to the parent directory path of the deletion destination path. As described above, since the parent directory path of the deletion destination path is the Recycle Bin path of the system disk, by renaming the parent directory path of the first path to the Recycle Bin path of the system disk, the first path (or the file corresponding to the first path) can be placed in the Recycle Bin of the system disk. It should be noted that the "modification" of the path described in the embodiments of the present application can be understood as "renaming" the path, and the two have the same or similar meanings.

[0046] The above is step S106, and then proceed to step S107.

[0047] In step S107, the target file in the NAS disk is placed in the recycle bin of the NAS disk.

[0048] In some embodiments, placing the target file in the NAS disk into the recycle bin of the NAS disk may be achieved by renaming the parent directory path of the target file in the NAS disk to the recycle bin path of the NAS disk.

[0049] Figure 2 This is a schematic diagram of a file deletion operation on a NAS disk provided in an embodiment of the present application. It should be noted that: Figure 2 The files in the system disk are shown in gray because in this embodiment, the system disk may not actually have the file, but only obtains the path of a file corresponding to the location, that is, the first path. Figure 2 As shown in , on a NAS disk, by renaming the path of the target file, the target file can be deleted, that is, the target file is placed in the Recycle Bin of the NAS disk. At the same time, by still renaming the path, the parent directory of the target file in the corresponding path on the system disk (that is, the parent directory of the first path) is renamed to the Recycle Bin directory of the system disk, so that the first path is located in the Recycle Bin directory of the system disk after the renaming.

[0050] The above is a description of the steps of a method for deleting files on a NAS disk provided by an embodiment of the present application. Next, this specification will explain the method for deleting files provided by this embodiment based on specific usage scenarios. Figure 3 This is a schematic diagram of a file deletion method based on a specific usage scenario provided by an embodiment of the present application. Figure 3 The file deletion method is described.

[0051] like Figure 3 As shown, there is a NAS Recycle Bin on the NAS disk, the target file x exists on the NAS disk, and there is a C drive Recycle Bin on the system disk. Figure 3 The file deletion method shown includes the following steps: receiving a deletion instruction for file x (i.e., a target file) in the NAS disk; determining whether the deletion instruction corresponds to a deletion operation on the file x, wherein if it is determined that the request corresponds to a deletion operation on the file x, obtaining a first path x' in the system disk corresponding to the file x; obtaining a deletion destination path of the first path x' and a parent directory path of the deletion destination path, wherein the deletion destination path corresponds to the deletion operation; determining whether the parent directory path of the deletion destination path is a recycle bin path of the system disk, wherein if the parent directory path of the deletion destination path is a recycle bin path of the system disk, modifying the parent directory path of the first path x' to the parent directory path of the deletion destination path; and placing the file x in the NAS disk into the recycle bin of the NAS disk.

[0052] In one possible embodiment, user User1 first creates and saves file x on the desktop corresponding to a NAS disk. The path for file x is N:\User1\a\b\x, where N is the volume corresponding to the NAS disk and N:\User1 is User1's home directory. The NAS disk is mounted on a local computer, which also includes local disk drive C. The user instructs the operating system to delete file x by right-clicking on file x and selecting Delete.

[0053] In some embodiments, the delete instruction for file x can be intercepted by, for example, the MiniFilter framework developed by Microsoft. MiniFilter has a matching filter driver, the Filter Manager. The Filter Manager provides various interfaces. MiniFilter can register the operations to be filtered with the Filter Manager driver and provide callback functions in a specified format for the Filter Manager to call. Developers can develop file system filter driver modules according to its specifications to customize file request operations. When a file processing request or operation occurs at the application layer, the request or operation is encapsulated by the I / O manager (input / output manager) into an IRP (IORequest Package) and transmitted to the underlying file processing system. After the task is completed, the file processing system encapsulates the task completion information and parameters into an IRP and transmits it back to the upper layer. MiniFilter can intercept the IRP passed by the application layer to the file processing system, record it, and return the task completion IRP to the application layer through a customized callback function. The system can interpret the received IRP as the normal completion of the request or operation, thereby allowing the system to insert customized logic within conventional system file operations. Since the MiniFilter framework operates in the system kernel state, the stability and security of file processing are guaranteed.

[0054] In some embodiments, determining whether the delete instruction corresponds to a delete operation on file x may include sequentially executing multiple predetermined operations on file x with delete permission, wherein if the multiple predetermined operations include a pre-delete operation and a pre-undelete operation, then the delete instruction corresponds to a delete operation on file x. For example, calling a delete_file function on file x, and if the call succeeds, determining that delete permission exists for file x, and then revoking the call.

[0055] In some embodiments, MiniFilter can determine that file x is located on a NAS disk based on the path hash value, that is, on a different disk from the system disk recycle bin. Then, the system closes the handle of file x, which is an integer that can uniquely identify file x.

[0056] In order to ensure that the file path of the opened file to be deleted and the recycle bin path used by the system later are on the same disk (in this case, the C drive), the file x on the NAS disk cannot be opened directly. Instead, a directory structure corresponding to the file x must be constructed on the system disk. Based on the path N:\User1\a\b\x on the NAS disk, the first path x' in the root directory of the system disk corresponding to the file x can be obtained as C:\a\b\x. Figure 3 As shown, the x' file in the upper right frame is gray, indicating that the x' file does not actually exist. x' simply represents the file that can be represented by the first path x' constructed on the C drive corresponding to the target file x. In this application, unless otherwise specified, x', x' file, and first path x' have the same or similar meanings.

[0057] According to the first path x', the parent directory path of the deletion target path can be obtained as the Recycle Bin path of drive C. For example, the parent directory path of the deletion target path (i.e., the Recycle Bin path of drive C) is: C:\$Recycle.Bin\s1, where s1 is the SID identifying the current local system user.

[0058] According to the above steps, the parent directory of the deletion destination path of the first path x' of the file x has been constructed as the recycle bin path of the system disk.

[0059] You can rename C:\a\b in the first path x' to C:\$Recycle.Bin\s1, where s1 is the SID corresponding to the current local system user. Figure 3 As shown, the dotted arrow from x' to the Recycle Bin of the C drive in the lower right box represents the process of renaming the path, wherein the dotted line represents that the process does not correspond to a process of a real file being placed in the Recycle Bin.

[0060] like Figure 3As shown in the figure, file x on the NAS disk is placed in the Recycle Bin of the NAS disk. The Recycle Bin of the NAS disk is an existing directory with a known path. The operation of placing file x in the NAS disk Recycle Bin can still be achieved by renaming the path. For example, the parent directory path N:\User1\a\b in the path of file x is renamed to N:\User1\Recycle\u1, where N:\User1\Recycle\u1 is the Recycle Bin directory belonging to user User1 on the NAS disk, and u1 is the SID of user User1 on the NAS disk.

[0061] The above is a detailed description of a NAS disk file deletion method based on a specific usage scenario provided by an embodiment of the present application. It can be seen that this method can effectively achieve data migration and maintain data security.

[0062] From the perspective of data migration, the embodiment provided by this application establishes an independent recycle bin on the NAS disk and provides a method for deleting files to the NAS recycle bin. Specifically, if the NAS disk does not have its own recycle bin (that is, the common traditional network disk file recycling logic), after the user deletes file x on the NAS disk, the file x will directly enter the recycle bin of the computer system disk currently used by the user, which is equivalent to completely deleting it from the NAS disk. When the user logs in to the NAS on another device, the previously deleted file x will not be accessible through the recycle bin, because the data of file x does not exist in the recycle bin of the current device. The deleted file x only exists in the computer system disk used when the user deleted the file. Based on the NAS disk file deletion method provided by this application, the deleted files on the NAS disk will enter the user's recycle bin on the NAS disk, and the path of the recycle bin is identified by the unique SID for the user. The user can access the NAS recycle bin and restore the files or data in the recycle bin when logging in to the NAS on different devices, thereby realizing the migration of NAS disk data.

[0063] From the perspective of data security, the NAS disk recycle bin and file deletion method provided in the embodiment of the present application can ensure that data between different users will not be crossed. Specifically, under the traditional network disk deletion logic, since the NAS disk does not have an independent recycle bin, when user A of the NAS disk deletes file a on his NAS disk, the file a will directly enter the computer system disk recycle bin currently used by user A. Afterwards, if another user B also uses the computer, he may obtain the data of file a deleted by user A by accessing the system local recycle bin, causing a leak. According to the NAS disk data method provided in the embodiment of the present application, when a NAS disk user deletes a file, the deleted file can enter the recycle bin of the NAS disk, and the NAS disk recycle bin directory is identified according to the user's SID. The SID of each user is different, and each user can only access the recycle bin under the user's directory. Different users will not cause data leakage due to using the same device, ensuring data security.

[0064] In some embodiments, application-layer hooking can be used to monitor and process file deletion instructions on NAS disks as an alternative to the aforementioned MiniFilter. Hooking refers to various techniques that modify or extend the behavior of an operating system, application, or other software component by intercepting function calls, message passing, or event delivery between software modules. The code that handles the intercepted function calls, events, and messages is called a hook.

[0065] In some embodiments, taking the Windows system as an example, Hooking can be implemented by configuring a DLL (dynamic link library, which usually contains functions and processes that can be used by other programs) or an EXE executable file (containing an entry point or the part of the code that should be used by the operating system to start executing the application). For example, a code is written in the DLL file, and the code is used to perform the file deletion operation described above on the file to be deleted after receiving a deletion instruction for the file on the NAS disk. The Hook can be configured so that as long as the process receives a message that can issue a Hook (corresponding to a file deletion request initiated by the user or the system), the DLL file of the Hook will be automatically or forcibly loaded into the process by the operating system to start running. The specific file deletion logic is the same as the file deletion logic under the MiniFilter framework mentioned above, and will not be repeated here.

[0066] It should be understood that in actual applications, Hook files may have different configurations and forms in different operating systems, and the specific Hook file execution process in different Hooking methods may also vary. The above-described NAS disk file deletion process using Hooking technology is merely exemplary and should not be considered to limit the scope of this application. Furthermore, Hooking technology and the aforementioned MiniFilter framework are only two preferred solutions for the NAS disk file deletion method. Other tools or technologies that can intercept and process messages or instructions to complete the NAS disk file deletion method described in this specification should also be included in the scope of protection of this application.

[0067] The above is an exemplary description of the NAS disk file deletion method provided by the embodiment of the present application. The embodiment of the present application also provides a NAS disk file deletion device, which receives a first instruction for a target file in the NAS disk. Figure 4 This is a structural diagram of a NAS disk file deletion device 400 provided in an embodiment of the present application. Figure 4 As shown, the apparatus 400 includes a path acquisition module 401, a determination module 402, and a deletion module 403. The apparatus 400 also includes an instruction receiving unit configured to receive a first instruction for a target file on a NAS disk. Each module in the apparatus 400 will be described in detail below.

[0068] The determination module 402 is configured to determine whether the first instruction corresponds to a deletion operation on the target file.

[0069] Determining whether the first instruction corresponds to a delete operation on the target file may include: executing multiple predetermined operations on the target file in sequence with delete permission based on the first instruction, wherein if the multiple predetermined operations include a pre-delete operation and a pre-undelete operation, then determining that the first instruction corresponds to a delete operation on the target file. The specific process and steps for determining whether the first instruction corresponds to a delete operation on the target file are described in detail in step S102 of the file deletion method 100 above. For details, please refer to S102 and will not be repeated here.

[0070] The determination module 402 may also be configured to record the thread ID and path hash value of the pre-deletion operation.

[0071] The judgment module 402 can also be configured to: open the target file with deletion permission before the path acquisition module 401 acquires the first path; determine whether the thread ID and path hash value of the operation of opening the target file match the thread ID and path hash value of the pre-deletion operation that have been recorded, respectively, wherein, if the thread ID and path hash value of the operation of opening the target file match the thread ID and path hash value of the pre-deletion operation that have been recorded, respectively, then obtain the first path in the system disk corresponding to the target file. The specific process of determining whether the thread ID and path hash value of the operation of opening the target file match the thread ID and path hash value of the pre-deletion operation that have been recorded is described in detail in the above-mentioned file deletion method 100. For specific details, please refer to method 100 and will not be repeated here.

[0072] The determination module 402 may also be configured to determine whether the parent directory path of the deletion destination path is a recycle bin path of the system disk.

[0073] The path acquisition module 401 is configured to: if the first instruction corresponds to a deletion operation on the target file, obtain a first path on the system disk corresponding to the target file. The specific process and steps of obtaining the first path are described in detail in the above-mentioned file deletion method 100 and will not be repeated here.

[0074] The path acquisition module 401 may also be configured to acquire a deletion destination path of the first path and a parent directory path of the deletion destination path, wherein the deletion destination path corresponds to the deletion operation. The specific process and steps of acquiring the deletion destination path of the first path and the parent directory path of the deletion destination path are described in detail in the above-mentioned file deletion method 100 and will not be repeated here.

[0075] The deletion module 403 is configured to: if the parent directory path of the deletion destination path is the recycle bin path of the system disk, modify the parent directory path in the first path to the parent directory path of the deletion destination path, and put the target file in the NAS disk into the recycle bin of the NAS disk.

[0076] The deletion module 403 may also be configured to modify the parent directory path of the target file to the recycle bin path of the NAS disk.

[0077] The specific process and steps of the deletion module modifying the first path and placing the target file into the recycle bin are described in detail in the above file deletion method 100 and will not be repeated here.

[0078] The present application also provides a computer-readable storage medium storing a computer program that, when executed, can perform all or part of the steps of the NAS disk file deletion method described in the exemplary embodiment above.

[0079] The present application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor is configured to execute the NAS disk file deletion method described in the above exemplary embodiment. The specific execution method has been described in detail in the embodiment of the file deletion method and will not be described in detail here.

[0080] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.

[0081] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor that supports the Advanced RISC Machines (ARM) architecture.

[0082] The above-mentioned software function module is stored in a storage medium, including several instructions for causing an electronic device (which may be a personal computer, a server, or a network device, etc.) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium may include a read-only memory and a random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DR RAM).

[0083] In the description of this specification, the reference terms "one embodiment," "some embodiments," "example," "specific example," or "some examples" mean that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials, or characteristics described may be combined in any appropriate manner in any one or more embodiments or examples. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification, as well as features of different embodiments or examples, unless they are mutually inconsistent.

[0084] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. Throughout the description of this application, "plurality" means two or more, unless otherwise specifically defined.

[0085] Any process or method described in the flowchart or otherwise described herein can be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process. The scope of the preferred embodiments of the present application includes other implementations in which the functions may be performed in a different order than shown or discussed, including performing the functions substantially simultaneously or in reverse order depending on the functions involved.

[0086] The logic and / or steps described in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with such instruction execution systems, apparatuses or devices.

[0087] It should be understood that various parts of the present application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.

[0088] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing module, or each module may exist physically separately, or two or more modules may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the aforementioned integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a magnetic disk, or an optical disk, etc.

[0089] The above is merely an exemplary embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various modifications or substitutions within the technical scope described in this application, and such modifications or substitutions should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A method for deleting files from a NAS disk, applicable to a NAS disk and a system disk, comprising: receiving a first instruction for a target file in the NAS disk; Determining whether the first instruction corresponds to a delete operation on the target file includes: performing a plurality of predetermined operations on the target file in sequence with a delete permission according to the first instruction, wherein if the plurality of predetermined operations include a pre-delete operation and a pre-undelete operation, then the first instruction corresponds to the delete operation on the target file; Record the thread ID and path hash value of the pre-deletion operation; Open the target file with delete permission; determining whether a thread ID and a path hash value of an operation to open the target file correspond to the recorded thread ID and path hash value of the pre-delete operation, wherein if the thread ID and the path hash value of the operation to open the target file match the recorded thread ID and the path hash value of the pre-delete operation, obtaining a first path in the system disk corresponding to the target file; If the first instruction corresponds to a deletion operation of the target file, obtaining a first path in the system disk corresponding to the target file; Acquire a deletion destination path of the first path and a parent directory path of the deletion destination path, wherein the deletion destination path corresponds to the deletion operation; and Determine whether the parent directory path of the deletion destination path is the recycle bin path of the system disk, wherein: If the parent directory path of the deletion destination path is a recycle bin path of the system disk, modifying the parent directory path of the first path to the parent directory path of the deletion destination path; and Put the target file in the NAS disk into the recycle bin of the NAS disk.

2. The method according to claim 1, wherein Putting the target file in the NAS disk into a recycle bin of the NAS disk includes: The parent directory path of the target file is modified to the recycle bin path of the NAS disk.

3. A device for deleting files on a NAS disk, which can be deployed on an electronic device where a system disk is located, a NAS disk, or other external device, wherein the external device can communicate and transmit data with the electronic device of the system disk and the NAS disk, and the device receives a first instruction for a target file on the NAS disk, wherein: The device comprises: a path acquisition module, configured to acquire a first path in the system disk corresponding to the target file if the first instruction corresponds to a deletion operation on the target file, and Acquire a deletion destination path of the first path and a parent directory path of the deletion destination path, wherein the deletion destination path corresponds to the deletion operation; A determination module configured to determine whether the first instruction corresponds to a deletion operation on the target file includes: According to the first instruction, a plurality of predetermined operations are sequentially performed on the target file with the deletion permission, wherein: If the plurality of predetermined operations include a pre-delete operation and a pre-undelete operation, determining that the first instruction corresponds to a delete operation of the target file, and recording a thread ID and a path hash value of the pre-delete operation; Open the target file with delete permission; Determine whether the thread ID and path hash value of the target file opening operation correspond to the recorded thread ID and path hash value of the pre-deletion operation, wherein, If the thread ID and path hash value of the target file opening operation match the recorded thread ID and path hash value of the pre-deletion operation, obtaining a first path in the system disk corresponding to the target file; and Determine whether the parent directory path of the deletion destination path is a recycle bin path of the system disk; a deletion module configured to modify the parent directory path of the first path to the parent directory path of the deletion destination path if the parent directory path of the deletion destination path is a recycle bin path of the system disk, and, Put the target file in the NAS disk into the recycle bin of the NAS disk.

4. The file deletion device according to claim 3, wherein: Putting the target file in the NAS disk into a recycle bin of the NAS disk includes: The parent directory path of the target file is modified to the recycle bin path of the NAS disk.

5. A computer-readable storage medium, wherein: The computer-readable storage medium includes a stored program, and when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the file deletion method for the NAS disk according to any one of claims 1 to 2.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the method according to any one of claims 1 to 2 is implemented.

Citation Information

Patent Citations

  • NAS distributed file system and data processing method

    CN111209259A

  • File system processing method, recycle bin management method, device and equipment

    CN114490516A