Cloud disk file management method and device and computer equipment
By marking folders as deleted status in the Cloud Disk Recycle Bin and separating the response and data deletion process, the problem of slow response when deleting a large number of files in the Cloud Disk system is solved, fast response and efficient file management are achieved, and user experience is improved .
Patent Information
- Application Number
- CN202411866654.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-01-14
AI Technical Summary
Cloud disk systems respond slowly when deleting a large number of files, which affects the user experience. The existing technology has failed to effectively solve this problem.
By marking the folder as deleted in the cloud disk recycling bin and modifying the folder as deleted after the subfile metadata is marked as deleted, separate the response and data deletion process, quickly respond and satisfy the Completely delete file data when conditions are required.
It improves the response speed of file deletion operations, making it independent of file size and number, and improves the cloud disk usage experience.
Smart Images

Figure CN119311649A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer application technology, and in particular to a cloud disk file management method, device and computer equipment. Background Art
[0002] With the rise of cloud computing, people have begun to pay attention to how to better manage and store data. Traditional local storage methods have some limitations, such as limited storage space, difficult data backup, and inconvenient cross-device access. Cloud disk is an online storage service developed based on cloud computing technology to solve these problems. Although cloud disk is more convenient for storage than local storage, it also has some problems.
[0003] In a cloud disk system, file metadata and file data itself are usually stored in different systems. File metadata is generally stored in the cloud disk business layer database table, while file data itself is stored in a distributed storage system. Compared with traditional local storage, the system needs to process steps such as obtaining all sub-files, deleting the file data of all sub-files in the distributed storage system and the file metadata in the business layer database table in sequence. The entire file deletion process involves longer links and takes longer time. Especially when deleting folders with a large number of files, such as a folder A containing multiple sub-folders, and these sub-folders contain many sub-sub-files, the deletion process will become more time-consuming. When the user clicks the delete button on the cloud disk interface, if the user needs to wait for the entire deletion process to complete before responding, the response will be very slow, which will affect the user experience.
[0004] With regard to the problem in related technologies that cloud disks respond slowly to file operations, no effective solution has been proposed so far. Summary of the invention
[0005] In this embodiment, a cloud disk file management method, apparatus, and computer device are provided to solve the problem of slow response of cloud disks in related technologies.
[0006] In a first aspect, a cloud disk file management method is provided in this embodiment, the method comprising: Receive a file deletion request sent by a user, and put the target object carried in the file deletion request into a cloud disk recycle bin; If the target object is a folder, the folder is marked as being deleted in the cloud disk recycle bin; Returning a file deletion completion response to the user, and marking the metadata of the sub-files contained in the folder as deleted; In response to metadata of sub-files contained in the folder being marked as deleted, modifying the folder to be in a deleted state; When the preset conditions are met, the file data in the folder marked as deleted is deleted.
[0007] In some of the embodiments, placing the target object carried in the file deletion request into a cloud disk recycle bin includes: Based on the target object carried in the file deletion request, modifying the non-deleted state in the metadata of the target object to a deleted state; In response to the metadata of the target object being successfully modified to a deleted state, a record of the target object is newly added in the cloud disk recycle bin to put the target object into the cloud disk recycle bin.
[0008] In some of the embodiments, when a preset condition is met, deleting the file data in the folder marked as deleted includes: In response to a request submitted by a user for completely deleting a folder marked as deleted, the deleted state of the folder is modified to a cleaning state; In response to successfully modifying the folder to the cleaning state, a complete file deletion response is returned to the user, and the file data in the folder marked as the cleaning state is deleted.
[0009] In some embodiments, deleting the file data in the folder marked as being cleaned up includes: Recording the data object identifiers of the sub-files in the folder marked as being cleaned in a data cleaning table; In response to the data object identification record being successfully added to the data cleaning table, deleting metadata of the folder and the sub-file of the folder, and deleting file data of the sub-file based on the data object identification in the data cleaning table; In response to the file data of the sub-file being deleted successfully, the corresponding data object identifier is deleted from the data cleaning table.
[0010] In some embodiments, the method further comprises: In response to the restart of the cloud disk system, it is determined whether there is a deleted folder in the cloud disk recycle bin. If so, the metadata of the sub-files contained in the folder that are not marked as deleted are marked as deleted.
[0011] In some embodiments, the method further comprises: In response to a file restoration request submitted by a user for a folder marked as deleted, determining whether a parent directory of the file exists based on a path of the folder; If it exists, the metadata of the folder and the sub-files under the folder are modified to be not deleted, and the mark of the folder and the sub-files under the folder in the cloud disk recycle bin is deleted.
[0012] In some embodiments, the method further comprises: In response to a request submitted by a user to create a new target folder in a parent directory, confirm whether metadata of the parent directory is in an undeleted state; If the metadata of the parent directory is in an undeleted state, then the metadata of the target folder is newly created, the metadata of the target folder is marked as being in an undeleted state, and the file path in the metadata is under the parent directory.
[0013] In some embodiments, the method further comprises: If the target object is a file, the metadata of the file is marked as deleted; When the preset condition is met, the file data in the folder whose metadata is marked as deleted is deleted.
[0014] In a second aspect, a cloud disk file management device is provided in this embodiment, and the device includes: A request receiving module, used to receive a file deletion request sent by a user, and put the target object carried in the file deletion request into a cloud disk recycle bin; A status marking module, for marking the folder as being deleted in the cloud disk recycle bin if the target object is a folder; The metadata modification module is used to return a file deletion completion response to the user and mark the metadata of the sub-files contained in the folder as deleted; a state modification module, configured to modify the folder to a deleted state in response to metadata of sub-files contained in the folder being marked as deleted; The complete deletion module is used to delete the file data in the folder marked as deleted when the preset conditions are met.
[0015] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the cloud disk file management method described in the first aspect is implemented.
[0016] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the cloud disk file management method described in the first aspect is implemented.
[0017] Compared with the related art, the cloud disk file management method, device and computer equipment provided in this embodiment receive a file deletion request sent by a user, and put the target object carried by the file deletion request into the cloud disk recycle bin; if the target object is a folder, the folder is marked as being deleted in the cloud disk recycle bin; a file deletion completion response is returned to the user, and the metadata of the sub-files contained in the folder are marked as deleted; in response to the metadata of the sub-files contained in the folder being marked as deleted, the folder is modified to a deleted state; when the preset conditions are met, the file data in the folder marked as deleted is deleted, which solves the problem of slow response of the cloud disk, realizes that the file deletion response time is independent of the file size, the number of files, etc., and improves the cloud disk usage experience.
[0018] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 The hardware structure block diagram of a terminal of a cloud disk file management method in one embodiment; Figure 2 A schematic diagram of a process of a cloud disk file management method in one embodiment; Figure 3 A schematic diagram of a process of deleting a target object in one embodiment; Figure 4 A schematic diagram of a data structure of cloud disk file management in one embodiment; Figure 5 A flowchart of a new file / folder operation in one embodiment; Figure 6 A flowchart of a file deletion operation in one embodiment; Figure 7 A flowchart of deleting a folder in one embodiment; Figure 8 A flowchart of a sub-file deletion task processing in an embodiment; Fig. 9 A flowchart of a task process of completely deleting a file / folder in one embodiment; Fig.10 A flowchart of a file cleaning task process in one embodiment; Fig.11 A flowchart of a data object cleaning task processing in one embodiment; Fig.12 A flowchart of a file / folder restoration process in one embodiment; Fig.13 A flowchart of a file / folder moving operation process according to an embodiment; Fig.14 A flowchart of a file / folder renaming process in one embodiment; Fig.15 It is a structural block diagram of a cloud disk file management device in one embodiment.
[0020] Figure numerals: 102, processor; 104, memory; 106, transmission device; 108, input and output device; 10, request receiving module; 20, status marking module; 30, metadata modification module; 40, status modification module; 50, complete deletion module. DETAILED DESCRIPTION
[0021] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0022] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0023] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1: is a hardware structure diagram of a terminal of the cloud disk file management method of this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 and a memory 104 for storing data, wherein the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0024] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the cloud disk file management method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0025] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0026] In this embodiment, a cloud disk file management method is provided, which is applicable to a cloud disk. A cloud disk is an online platform that can store and manage user files. Users can upload files to the cloud disk through the network and can access and share these files anytime and anywhere.
[0027] The business system of the cloud disk refers to a set of software systems that interact with users, manage files, and provide services running on the cloud disk platform. Common functions include the following: 1) User management: The cloud disk business system provides user registration, login, and account management functions. Users can log in to the cloud disk platform with their account and password to manage their personal information, including account settings, password changes, etc.; 2) File management: The cloud disk business system allows users to upload, download, create folders, view file lists, and other operations. Users can intuitively manage their own files and folders through the interface, and perform operations such as copying, moving, renaming, and deleting; 3) File sharing: The cloud disk business system supports users to share files and folders with others, and can control the scope and permission level of sharing by setting permissions.
[0028] The distributed storage system provides the underlying data storage and access capabilities for the cloud disk business system. The cloud disk business system receives user file upload requests and stores the file metadata in the business layer database. The file data itself is stored in the distributed storage system, and the file metadata records the data object identifier (data object key) of the file data in the underlying distributed storage system. The file data can be subsequently queried or deleted through this identifier information.
[0029] The file data itself refers to the actual content stored in the file. It is composed of binary data and can contain various types of data, such as text, images, audio, video, etc. The file data itself is represented by a data object below. If the file type is a folder, its file size is 0, and there can be only metadata but no data object.
[0030] File metadata is descriptive information about a file. It includes the file's attributes and features, but does not include the file's actual content. Common file metadata includes file path, file name, type (file or folder, which can also be called a directory), size, creation time, modification time, access rights, etc. File metadata records basic information about a file and can be used to help users and systems manage and locate files.
[0031] Figure 2 is a flow chart of the cloud disk file management method of this embodiment. Figure 2 As shown, the process includes the following steps: Step S210: receiving a file deletion request sent by a user, and placing the target object carried in the file deletion request into a cloud disk recycle bin.
[0032] Specifically, the target object includes files and folders, and folders are also called directories. In response to a file deletion request, the file is not displayed under its path, and the file is only displayed in the cloud disk recycle bin. The deletion mark in the metadata of the target object can be changed to hide the target object under the original path, and the name, path, deletion time, recycling status and other deletion record data of the target object are stored in the cloud disk recycle bin. In one embodiment, two tables are established to store the metadata and deletion record data of the target object respectively. In other embodiments, the metadata and deletion record data of the target object are recorded in one table at the same time.
[0033] Step S220: If the target object is a folder, the folder is marked as being deleted in the cloud disk recycle bin.
[0034] For details, see Figure 3 In the case of deleting a folder, new deletion record data for the folder is created, and the recovery status in the deletion record data is marked as being deleted.
[0035] Step S230: Return a file deletion completion response to the user, and mark the metadata of the sub-files contained in the folder as deleted.
[0036] Specifically, the metadata of newly created folders and files are usually marked as not deleted. When users view my file list in the cloud disk system, they will only query the target objects whose metadata is marked as not deleted. When the folder is put into the recycle bin in response to the file deletion request, the metadata status of the sub-files under the folder is modified, so that the sub-files are not displayed. It takes time to modify the metadata of all sub-files. This embodiment does not need to wait for the sub-files to be modified before responding to the user. Instead, it detects that the recycling status of the file is in the deleting state and returns the file deletion completion response to the user, which improves the response speed and gives the user a better user experience.
[0037] Step S240: in response to the metadata of the sub-files contained in the folder being marked as deleted, modifying the folder to be in a deleted state.
[0038] Step S250, when a preset condition is met, the file data in the folder marked as deleted is deleted.
[0039] Specifically, the folders marked as deleted in the cloud disk recycle bin are not completely deleted, but are only hidden from the user, and can be restored or completely deleted as needed. For example, after a certain period of time or upon a customer's request, the deleted folders are restored or the files and data in the folders are permanently deleted.
[0040] In this embodiment, a file deletion request sent by a user is received, and the target object carried in the file deletion request is placed in the cloud disk recycle bin; if the target object is a folder, the folder is marked as being deleted in the cloud disk recycle bin; a file deletion completion response is returned to the user, and the metadata of the sub-files contained in the folder are marked as deleted; in response to the metadata of the sub-files contained in the folder being marked as deleted, the folder is modified to a deleted state; when a preset condition is met, the file data in the folder marked as deleted is deleted, which solves the problem of slow response of the cloud disk and realizes that the file deletion response time is independent of the file size, the number of files, etc., thereby improving the cloud disk usage experience.
[0041] In some of the embodiments, based on step S210, placing the target object carried in the file deletion request into the cloud disk recycle bin includes: Step S211: based on the target object carried in the file deletion request, modify the non-deleted state in the metadata of the target object to a deleted state.
[0042] Step S212, in response to the metadata of the target object being successfully modified to a deleted state, a record of the target object is added in the cloud disk recycle bin to put the target object into the cloud disk recycle bin.
[0043] For details, see Figure 4 , when the target object is created, the metadata of the target object is recorded in the file table file, such as object identifier (file_id), parent directory identifier (parent_id), user identifier (user_id), file type (tpye), data object identifier (obj_key), file name (name), file size (size), and deletion mark (is_delete). The deletion mark is_delete=0 of the newly created target object (that is, the metadata is marked as not deleted). When the user views my file list in the cloud disk system, only the files with is_delete=0 will be queried. When the deletion operation is performed, the is_delete field of the file table record corresponding to the target object is modified to 1. After the is_delete field is successfully modified to 1, a record with the same object identifier is added to the recycle_bin table of the recycle bin. The recycle bin table is used to record the deletion records of file objects. The deletion records include the object identifier (file_id), user identifier (user_id), recycling status (state), file path (path), and deletion time (delete_time).
[0044] In one specific implementation, it is necessary to determine whether the metadata deletion flag of the target object is updated successfully. There is a difference between changing the deletion flag is_delete from 0 to 1 and setting the deletion flag is_delete to 1. Here is an explanation: The former corresponds to the SQL statement "update file set is_delete = 1 where file_id = cloud disk file management and is_delete = 0". The latter corresponds to the SQL statement "update file set is_delete = 1 where file_id = cloud disk file management". If a file has been deleted, that is, is_delete = 1, when executing the first SQL statement, the number of affected file records is 0, and when executing the second SQL statement, the number of affected rows is 1. By judging whether the number of affected rows is greater than 0, it is determined whether the update is successful. Using the second SQL statement will cause a deleted file to be deleted repeatedly, which is not allowed logically.
[0045] In this embodiment, by modifying the deletion flag of the metadata and adding a deletion record, the folder is simply and quickly moved into the cloud disk recycle bin.
[0046] In some of these embodiments, based on step S250, when a preset condition is met, the file data in the folder marked as the deleted state is deleted, including: Step S251, in response to a request from the user to completely delete the folder marked as the deleted state, change the deleted state of the folder to the cleaning state.
[0047] Step S252, in response to successfully changing the folder to the cleaning state, return a response indicating that the file has been completely deleted to the user, and delete the file data in the folder marked as the cleaning state.
[0048] Specifically, change the recovery state state of the recycle bin record from the deleted state Deleted to the cleaning state Cleaning, and then asynchronously send a message to the file cleaning task for further processing. Without waiting for the file cleaning task to complete, the response to the user for the complete deletion operation is completed. Therefore, regardless of the number of files and the size of the files in the folder, the response time of the complete deletion interface to the user is fixed, which speeds up the response speed and improves the user experience.
[0049] In some of these embodiments, based on step S252, the file data in the folder marked as the cleaning state is deleted, including: Step S310, record the data object identifier of the sub-files in the folder marked as the cleaning state in the data cleaning table.
[0050] For details, see Figure 4 In order to completely delete the file, a data object table to be cleaned up obj_clean is established, and at least the object identifier file_id, the user identifier user_id and the data object identifier obj_key are recorded in obj_clean.
[0051] Step S320, in response to the data object identification record being successfully added to the data cleaning table, the metadata of the folder and the sub-files of the folder are deleted, and based on the data object identification in the data cleaning table, the file data of the sub-file is deleted.
[0052] Specifically, the metadata recorded in the file table of the folder itself and all its sub-files is deleted. One thing to note here is that file cleaning needs to filter out sub-files that are also in the Recycle Bin. For example, there is directory A and file B, and B is a sub-file of A. First, add sub-file B to the Recycle Bin, then add parent directory A to the Recycle Bin, and then completely delete directory A. At this time, sub-file B cannot be cleaned when cleaning directory A, because B is still in the Recycle Bin. Only by completely deleting B from the Recycle Bin can file B be cleaned.
[0053] Step S330: In response to the successful deletion of the file data of the sub-file, the corresponding data object identifier is deleted from the data cleaning table.
[0054] Specifically, the data object cleaning message subscription thread obtains the data object to be cleaned from the obj_clean table, calls the interface of the distributed storage system to delete the data object, and deletes the obj_clean table record after ensuring that the data object is successfully deleted. Only then is a file considered to be completely deleted.
[0055] In some of the embodiments, the method also includes: in response to the restart of the cloud disk system, determining whether there is a folder in the cloud disk recycle bin in a cleaning state; if so, deleting the metadata of the folder and the folder's sub-files, and deleting the file data of the sub-file based on the data object identifier in the data cleaning table; in response to successful deletion of the file data of the sub-file, deleting the corresponding data object identifier in the data cleaning table.
[0056] In some of the embodiments, the method further includes: in response to the restart of the cloud disk system, determining whether there is a folder in a deleted state in the cloud disk recycle bin; if so, marking the metadata of the sub-files contained in the folder that are not marked as deleted as deleted.
[0057] Specifically, a FIFO (first-in-first-out queue) is used to mark the metadata of all sub-files as deleted, starting from the deleted folder, by means of breadth-first traversal. For example, there is a directory / A / B / C, There is a file A.txt and a directory B under directory A, a file B.txt and a directory C under directory B, and a file C.txt under directory C. At this time, folder A is deleted, and the file deletion operation in the previous step changes the deletion mark is_delete of A from 0 to 1, and then the sub-file deletion task is handed over to asynchronously process the sub-files under directory A. Since the deletion mark of A is 1, it can be ensured that no new files can be added to the first child level of A. Therefore, a SQL statement update file set is_delete= 1 where parent_id = A and is_delete = 0 can be used to change the deletion mark of the next-level sub-file from 0 to 1. In contrast, since the level of folder C and C.txt has not been processed at this time, in fact, if there is a concurrent transaction to add a file to folder C at this time, since the deletion mark is_delete of C is still 0, it can be added. When folder C is processed, the deletion mark of the sub-files under C will also be changed from 0 to 1. Since we process from top to bottom, no new files can be added under the processed level. When all levels are processed, it can be guaranteed that no undeleted files will appear under the deleted folders (even if there are concurrent new file transactions, the consistency of the final result can be guaranteed).
[0058] In this embodiment, the folders in the deleted state are confirmed to prevent new files from being added or moved to the deleted folders during the restart process, which would affect the consistency of the information in the cloud disk recycle bin and cause deletion exceptions. The steps of this embodiment belong to the background execution process and are not perceived by the user.
[0059] In some of these embodiments, the method further comprises: Step S410, in response to a file restoration request submitted by a user for a folder marked as deleted, it is determined whether a parent directory of the file exists based on the path of the folder.
[0060] Step S420: If it exists, the metadata of the folder and the sub-files under the folder are modified to be not deleted, and the mark of the folder and the sub-files under the folder in the cloud disk recycle bin is deleted.
[0061] Specifically, only files in the deleted state can be restored. To prevent the impact of concurrent transactions, the first step is to lock the recycle_bin record. The path field in the recycle_bin table records the path name of the file, such as / A / B / C, to prevent the directory from being deleted or renamed. When restoring files, the directory on the path needs to be automatically restored (if it does not exist, create a new one; if it already exists, lock it to avoid being modified by other concurrent transactions during the restoration process, resulting in inconsistent data). Change the deletion mark is_delete of the file record from 1 to 0. The modification may fail due to file name conflicts. If a name conflict occurs, it will be automatically renamed and retried until there is no conflict. Delete the recycle_bin table record in the Recycle Bin. If it is a folder, you also need to change the deletion mark is_delete of the sub-file from 1 to 0 (one thing to note here is that when restoring files, you need to exclude the files in the Recycle Bin. For example, there is a directory A and a file B, and B is a sub-file of A. First add the sub-file B to the Recycle Bin, then add the parent directory A to the Recycle Bin, and then restore the A directory. At this time, the sub-file B cannot be restored because B is still in the Recycle Bin).
[0062] In some of these embodiments, the method further comprises: Step S510, in response to a request submitted by a user to create a new target folder in a parent directory, confirm whether the metadata of the parent directory is in an undeleted state.
[0063] Step S520: If the metadata of the parent directory is in an undeleted state, metadata of the target folder is newly created, the metadata of the target folder is marked as being in an undeleted state, and the file path in the metadata is under the parent directory.
[0064] Specifically, when creating a new file in a directory, in order to prevent concurrent transactions from modifying the parent directory, the parent directory needs to be locked, and the deletion mark is_delete of the parent directory needs to be checked to see if it is equal to 0. Only in directories that have not been deleted can new files be created. If the parent directory is not locked, and a concurrent transaction deletes the parent directory, the parent directory will eventually be deleted, but the child files under the parent directory will not be deleted. Logically, the data is inconsistent. If only the parent directory is locked, although no concurrent transactions can be executed, the deletion mark is_delete may be equal to 1, indicating that the parent directory has been deleted. At this time, if a new file is added to the parent directory, the parent directory will also be deleted, but the child files under the parent directory will not be deleted. Data inconsistency. Therefore, locking the parent directory and checking whether the parent directory has not been deleted are both indispensable. The file metadata processing logic for adding files and folders is the same, except that adding files requires an additional process of uploading file data to the distributed storage system.
[0065] In some of the embodiments, see Figure 3 , the method further comprises: Step S260: If the target object is a file, the metadata of the file is marked as deleted.
[0066] Step S270, when the preset condition is met, the file data in the folder whose metadata is marked as deleted is deleted.
[0067] Specifically, files marked as deleted by metadata are not completely deleted, but are only hidden from users. They can be restored or completely deleted as needed. For example, when a certain time has passed or a customer's request is received, the folder whose metadata is deleted is restored or the file data in the folder is permanently deleted. When responding to a complete file deletion operation, the data object key corresponding to the file is added to the data object cleanup queue (the corresponding table is obj_clean), and finally the file table file record and the recycle bin table recycle_bin record are deleted; data object cleanup task processing logic: continuously obtain the object key that needs to be cleaned from the obj_clean table, call the deletion interface of the distributed storage system, and ensure that the deletion is successful before removing the key from the obj_clean table.
[0068] The present embodiment is described and illustrated below through preferred embodiments.
[0069] See also Figure 3 and Figure 4 , the newly created file will be stored in the file table file, and its deletion mark is_delete = 0. When the user views my file list in the cloud disk system, only the files with is_delete = 0 will be queried.
[0070] When executing a file deletion operation, the is_delete field of the file table record corresponding to the file is set to 1, and a record with the same file id is added to the recycle_bin table of the recycle bin. If it is a file, the state of recycle_bin is set to Deleted (deleted state, indicating that all deletion logic has been executed); if it is a folder, the state is set to Deleting (deleting state, indicating that sub-files need to be processed). The above operations are processed in one transaction, and an optimistic lock update mechanism is used to prevent the impact of concurrent transactions. After the transaction is committed, a message is asynchronously sent to the sub-file deletion task for the next step of processing. There is no need to wait for the sub-file deletion task to be executed, and the user is responded to that the file deletion operation is completed, which improves the response speed.
[0071] The sub-files under the folder form a multi-branch tree structure. Assuming that the tree has n levels, the tree is processed in a breadth-first traversal manner. Each time it is processed, the first-level child nodes directly under a node are deleted at one time (the is_delete field of the file table record is marked as 1). If there is a folder in the first-level child node directly, the sub-folder needs to be processed recursively. When the is_delete field of all nodes in this tree is set to 1, the deletion logic of the folder is considered to be fully executed. Finally, the state of the recycle bin record is changed from Deleting to Deleted. When the user views the file list in the recycle bin, only the files with state = Deleted will be queried. It should be noted that although this step of the processing process is a bit troublesome, it is a background execution process and the user is not aware of it. When the Recycle Bin is emptied or a file is completely deleted from the Recycle Bin, the state of the Recycle Bin record is changed from Deleted to Cleaning (indicating the cleaning state), and then a message is asynchronously sent to the file cleaning task for the next step of processing. This responds to the user that the complete deletion operation is completed without waiting for the file cleaning task to be executed, thereby improving the response speed.
[0072] File cleaning task processing logic: If it is a file, add the data object key corresponding to the file to the data object cleaning queue (the corresponding table is obj_clean); if it is a folder, add the data object keys of all sub-files to the data object cleaning queue, and finally delete the file table file record and the recycle bin table recycle_bin record.
[0073] Data object cleaning task processing logic: continuously obtain the object key that needs to be cleaned from the obj_clean table, call the deletion interface of the distributed storage system, and ensure that the deletion is successful before removing the key from the obj_clean table.
[0074] See also Figure 5 , the new file / folder operation process is as follows: 1. When creating a new file in a directory, in order to prevent concurrent transactions from modifying the parent directory, the parent directory needs to be locked, and the deletion mark is_delete of the parent directory is checked to see if it is equal to 0. Only new files can be created in directories that have not been deleted.
[0075] 2. If the parent directory is not locked, and a concurrent transaction deletes the parent directory, the parent directory will eventually be deleted, but the child files under the parent directory will not be deleted. Logically speaking, the data is inconsistent.
[0076] 3. If only the parent directory is locked, although no concurrent transactions can be executed, the deletion mark is_delete may be equal to 1, indicating that the parent directory has been deleted. At this time, if new files are added to the parent directory, the parent directory will be deleted, but the child files in the parent directory will not be deleted. Data inconsistency problem will occur. Therefore, locking the parent directory and checking whether the parent directory has been deleted are both indispensable. 4. The file metadata processing logic for newly added files and newly added folders is the same, except that newly added files have an additional process of uploading file data to the distributed storage system.
[0077] See also Figure 6 , the file deletion process is as follows: 1. Change the delete flag is_delete of the file table record from 0 to 1.
[0078] 2. After the deletion mark is modified successfully, a new record is added to the recycle bin table recycle_bin, and the file / folder is moved to the recycle bin.
[0079] See also Figure 7 , the process of deleting a folder is as follows: 1. Change the delete flag is_delete of the file table record from 0 to 1.
[0080] 2. After the deletion mark is modified successfully, a new record is added to the recycle bin table recycle_bin, in which the recycling status is marked as Deleting. At the same time, the sub-file deletion task message is sent asynchronously, and the message subscription thread is responsible for asynchronously processing the sub-file deletion process. Therefore, no matter how many files are in the folder, the folder deletion interface responds to the user for a fixed time, which improves the user experience.
[0081] See also Figure 8 , the sub-file deletion task processing flow is as follows: 1. Since the is_delete flag of the folder has been changed from 0 to 1 in the previous folder deletion step, and the operation of adding files has locked the parent folder and verified whether the is_delete flag is 0, as long as the folder is deleted, it can be ensured that no files can be added to the next level of the folder.
[0082] 2. Use FIFO (first-in-first-out queue), starting from the deleted folder, and change the is_delete flag of all sub-files from 0 to 1 through breadth-first traversal. Since the process is done from top to bottom, no new files can be added to the processed levels. When all levels are processed, it can be guaranteed that there will be no undeleted files in the deleted folder (even if there are concurrent new file transactions, the consistency of the final result can be guaranteed).
[0083] See also Fig. 9 , the task processing flow for completely deleting files / folders is as follows: Deleting files / folders actually adds files / folders to the Recycle Bin, and the data is still there. The file data will be truly deleted only when the Recycle Bin is emptied or some files in the Recycle Bin are selected for complete deletion. The step of completely deleting files is just to mark the recycling status of the records in the recycle_bin table of the Recycle Bin from Deleted to Cleaning. After the recycling status is changed from Deleted to Cleaning, a file cleaning task message is sent, and the message subscriber is responsible for asynchronously processing the file cleaning process. Therefore, no matter how many files are in the folder or how large the files are, the response time of the complete deletion interface to the user is fixed, which improves the user experience.
[0084] See also Fig.10 , the file cleaning task processing flow is as follows: delete the file records of the folder itself and all sub-files (one thing to note here is that file cleaning needs to filter out sub-files that are also in the Recycle Bin. For example, there is a directory A and a file B, B is a sub-file of A, first add the sub-file B to the Recycle Bin, then add the parent directory A to the Recycle Bin, and then completely delete the A directory. At this time, the sub-file B cannot be cleaned when cleaning the A directory, because B is still in the Recycle Bin. Only by completely deleting B from the Recycle Bin can the file B be cleaned), and at the same time, add the file data object key to the data object table to be cleaned, obj_clean, and then send the data object cleaning task message asynchronously. The message subscriber is responsible for asynchronously processing the data object cleaning process.
[0085] See also Fig.11 ,The data object cleaning task processing process is as follows: the data object cleaning message subscription thread ,obtains the data object that needs to be cleaned from the obj_clean table, and calls the interface of the ,distributed storage system to delete the data object, and then deletes the obj_clean table record after ensuring that the data object is deleted successfully. ,At this time, a file is considered to be completely deleted.
[0086] In addition to being completely deleted, files in the Recycle Bin may also be restored. For the sake of completeness, the following is an introduction to the file restoration process.
[0087] See also Fig.12 , the file / folder restore process is as follows: 1. Only files in the Deleted state can be restored, and to prevent the impact of concurrent transactions, the first step is to lock the recycle_bin record.
[0088] 2. The path field in the recycle_bin table of the recycle bin records the path name of the file, such as / A / B / C, to prevent the directory from being deleted or renamed. When restoring the file, the directory on the path needs to be automatically restored (if it does not exist, create a new one; if it already exists, lock it to avoid being modified by other concurrent transactions during the restoration process, resulting in data inconsistency).
[0089] 3. Change the deletion mark is_delete of the file record from 1 to 0. The modification may fail due to file name conflicts. If a name conflict occurs, it will automatically rename and try again until there is no conflict.
[0090] 4. Delete the records in the recycle_bin table of the Recycle Bin. If it is a folder, you also need to change the deletion mark is_delete of the sub-file from 1 to 0 (one thing to note here is that when restoring files, you need to exclude the files in the Recycle Bin. For example, there is a directory A and a file B, and B is a sub-file of A. First add the sub-file B to the Recycle Bin, then add the parent directory A to the Recycle Bin, and then restore the A directory. At this time, the sub-file B cannot be restored because B is still in the Recycle Bin).
[0091] See also Fig.13 , the file / folder move operation process is as follows: 1. Query and lock the file record of the file, and determine whether the deletion mark is_delete is equal to 0 to ensure that only non-deleted files can be moved.
[0092] 2. In order to prevent concurrent transactions from modifying the target directory, you need to lock the target directory and check whether the delete mark is_delete of the target directory is equal to 0 to ensure that files can only be moved into directories that have not been deleted.
[0093] 3. The above two steps can ensure data consistency and avoid the existence of undeleted files in deleted directories.
[0094] 4. Finally, just modify the parent_id of the file record to the target directory file_id.
[0095] See also Fig.14 , the file / folder renaming process is as follows: 1. Query and lock the file record of the file, and determine whether the deletion mark is_delete is equal to 0 to ensure that only non-deleted files can be renamed.
[0096] 2. Simply modify the name of the file record.
[0097] In this preferred embodiment, the process of adding files to the recycle bin is divided into two stages: synchronous deletion marking and asynchronous sub-file deletion marking. The user is responded to as soon as the synchronous stage is completed, thereby improving the user response speed of the file deletion operation; the process of completely deleting files is divided into three stages: synchronous cleanup marking, asynchronous file cleanup, and asynchronous data object cleanup. The user is responded to as soon as the synchronous stage is completed, thereby improving the user response speed of the complete file deletion operation.
[0098] In this embodiment, a cloud disk file management device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated here. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0099] Fig.15 is a structural block diagram of the cloud disk file management device of this embodiment. Fig.15 As shown, the device includes: a request receiving module 10, a state marking module 20, a metadata modification module 30, a state modification module 40, and a complete deletion module 50.
[0100] The request receiving module 10 is used to receive a file deletion request sent by a user and put the target object carried in the file deletion request into a cloud disk recycle bin.
[0101] The status marking module 20 is used to mark the folder as being deleted in the cloud disk recycle bin if the target object is a folder.
[0102] The metadata modification module 30 is used to return a file deletion completion response to the user and mark the metadata of the sub-files contained in the folder as deleted.
[0103] A state modifying module 40, configured to modify a folder to a deleted state in response to metadata of sub-files contained in the folder being marked as deleted; The complete deletion module 50 is used to delete the file data in the folder marked as deleted when a preset condition is met.
[0104] In some of the embodiments, placing the target object carried in the file deletion request into a cloud disk recycle bin includes: based on the target object carried in the file deletion request, modifying the non-deleted state in the metadata of the target object to a deleted state; in response to the metadata of the target object being successfully modified to a deleted state, adding a record of the target object in the cloud disk recycle bin to place the target object into the cloud disk recycle bin.
[0105] In some of the embodiments, when a preset condition is met, file data in a folder marked as deleted is deleted, including: in response to a request submitted by a user to completely delete the folder for the folder marked as deleted, the deleted status of the folder is changed to a cleaning status; in response to successfully changing the folder to the cleaning status, a complete file deletion response is returned to the user, and the file data in the folder marked as the cleaning status is deleted.
[0106] In some embodiments, deleting file data in the folder marked as being in a cleaning state includes: recording a data object identifier of a sub-file in the folder marked as being in a cleaning state in a data cleaning table; in response to successful addition of the data object identifier record in the data cleaning table, deleting metadata of the folder and the sub-files of the folder, and deleting file data of the sub-file based on the data object identifier in the data cleaning table; in response to successful deletion of the file data of the sub-file, deleting the corresponding data object identifier in the data cleaning table.
[0107] In some of the embodiments, the method further includes: in response to the restart of the cloud disk system, determining whether there is a folder in a deleted state in the cloud disk recycle bin, and if so, marking the metadata of the sub-files contained in the folder that are not marked as deleted as deleted.
[0108] In some of the embodiments, the method further includes: in response to a file restore request submitted by a user for a folder marked as deleted, determining whether the parent directory of the file exists based on the path of the folder; if it exists, modifying the metadata of the folder and the sub-files under the folder to not be deleted, and deleting the mark of the folder and the sub-files under the folder in the cloud disk recycle bin.
[0109] In some of the embodiments, the method further includes: in response to a request submitted by a user to create a new target folder in a parent directory, confirming whether the metadata of the parent directory is in an undeleted state; if the metadata of the parent directory is in an undeleted state, creating new metadata for the target folder, marking the metadata of the target folder as being in an undeleted state, and having the file path in the metadata be under the parent directory.
[0110] In some of the embodiments, the method further includes: if the target object is a file, marking the metadata of the file as deleted; when a preset condition is met, deleting the file data in the folder where the metadata is marked as deleted.
[0111] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0112] In this embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0113] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0114] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.
[0115] In addition, in combination with the cloud disk file management method provided in the above embodiments, a storage medium may also be provided in this embodiment to implement the method. The storage medium stores a computer program; when the computer program is executed by the processor, any one of the cloud disk file management methods in the above embodiments is implemented.
[0116] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.
[0117] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.
[0118] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0119] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.
Claims
1. A cloud disk file management method, characterized in that: The method comprises: Receive a file deletion request sent by a user, and put the target object carried in the file deletion request into a cloud disk recycle bin; If the target object is a folder, the folder is marked as being deleted in the cloud disk recycle bin; Returning a file deletion completion response to the user, and marking the metadata of the sub-files contained in the folder as deleted; In response to metadata of sub-files contained in the folder being marked as deleted, modifying the folder to be in a deleted state; When the preset conditions are met, the file data in the folder marked as deleted is deleted.
2. The cloud disk file management method according to claim 1, characterized in that: Putting the target object carried in the file deletion request into the cloud disk recycle bin, including: Based on the target object carried in the file deletion request, modifying the non-deleted state in the metadata of the target object to a deleted state; In response to the metadata of the target object being successfully modified to a deleted state, a record of the target object is newly added in the cloud disk recycle bin to put the target object into the cloud disk recycle bin.
3. The cloud disk file management method according to claim 1, characterized in that: When the preset conditions are met, the file data in the folder marked as deleted will be deleted, including: In response to a request submitted by a user for completely deleting a folder marked as deleted, the deleted state of the folder is modified to a cleaning state; In response to successfully modifying the folder to the cleaning state, a complete file deletion response is returned to the user, and the file data in the folder marked as the cleaning state is deleted.
4. The cloud disk file management method according to claim 3, characterized in that: Delete the file data in the folder marked as being cleaned, including: Recording the data object identifiers of the sub-files in the folder marked as being cleaned in a data cleaning table; In response to the data object identification record being successfully added to the data cleaning table, deleting metadata of the folder and the sub-file of the folder, and deleting file data of the sub-file based on the data object identification in the data cleaning table; In response to the file data of the sub-file being deleted successfully, the corresponding data object identifier is deleted from the data cleaning table.
5. The cloud disk file management method according to claim 1, characterized in that: The method further comprises: In response to the restart of the cloud disk system, it is determined whether there is a deleted folder in the cloud disk recycle bin. If so, the metadata of the sub-files contained in the folder that are not marked as deleted are marked as deleted.
6. The cloud disk file management method according to claim 1, characterized in that: The method further comprises: In response to a file restoration request submitted by a user for a folder marked as deleted, determining whether a parent directory of the file exists based on a path of the folder; If it exists, the metadata of the folder and the sub-files under the folder are modified to be not deleted, and the mark of the folder and the sub-files under the folder in the cloud disk recycle bin is deleted.
7. The cloud disk file management method according to claim 1, characterized in that: The method further comprises: In response to a request submitted by a user to create a new target folder in a parent directory, confirm whether metadata of the parent directory is in an undeleted state; If the metadata of the parent directory is in an undeleted state, then new metadata of the target folder is created, the metadata of the target folder is marked as being in an undeleted state, and the file path in the metadata is under the parent directory.
8. The cloud disk file management method according to claim 1, characterized in that: The method further comprises: If the target object is a file, the metadata of the file is marked as deleted; When the preset condition is met, the file data in the folder whose metadata is marked as deleted is deleted.
9. A cloud disk file management device, characterized in that: The device comprises: A request receiving module, used to receive a file deletion request sent by a user, and put the target object carried in the file deletion request into a cloud disk recycle bin; A status marking module, for marking the folder as being deleted in the cloud disk recycle bin if the target object is a folder; The metadata modification module is used to return a file deletion completion response to the user and mark the metadata of the sub-files contained in the folder as deleted; a state modification module, configured to modify the folder to a deleted state in response to metadata of sub-files contained in the folder being marked as deleted; The complete deletion module is used to delete the file data in the folder marked as deleted when the preset conditions are met.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Distributed file processing method and device, computer equipment and storage medium
CN109857719A
Data partitioning method
CN110737635A
Recycle bin system and file recycling method
CN110888847A
Method and system for safely deleting files in cloud disk recycle bin
CN115757294A
File management method and electronic equipment
CN118092726A