CN109828962B - Method, device, server and storage medium for preventing file from being deleted by mistake - Google Patents

Method, device, server and storage medium for preventing file from being deleted by mistake Download PDF

Info

Publication number
CN109828962B
CN109828962B CN201811556213.7A CN201811556213A CN109828962B CN 109828962 B CN109828962 B CN 109828962B CN 201811556213 A CN201811556213 A CN 201811556213A CN 109828962 B CN109828962 B CN 109828962B
Authority
CN
China
Prior art keywords
file
deleted
item
directory
identifier
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811556213.7A
Other languages
Chinese (zh)
Other versions
CN109828962A (en
Inventor
申航
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN201811556213.7A priority Critical patent/CN109828962B/en
Publication of CN109828962A publication Critical patent/CN109828962A/en
Application granted granted Critical
Publication of CN109828962B publication Critical patent/CN109828962B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The disclosure relates to a method, a device, a server and a storage medium for preventing file from being deleted by mistake, wherein the method comprises the following steps: receiving a setting instruction of a sub item undeletable identifier, wherein the setting instruction of the sub item undeletable identifier comprises a directory of a sub item undeletable identifier to be set; and setting a sub-item undeletable identifier for the index node of the directory according to the sub-item undeletable identifier setting instruction so as to prevent the first-level sub-item of the directory from being deleted by mistake. The method and the device effectively avoid the mistaken deletion of the files in the network shared file storage system, and improve the safety of the files in the network shared file storage system.

Description

Method, device, server and storage medium for preventing file from being deleted by mistake
Technical Field
The present disclosure relates to the field of file sharing technologies, and in particular, to a method, an apparatus, a server, and a storage medium for preventing a file from being deleted by mistake.
Background
At present, more and more attention is paid to team cooperation in each field, and a network shared file storage system provides a file sharing function and brings convenience for team cooperation, so that the network shared file storage system is a strong demand which is not negligible in team cooperation.
Due to the openness of the network shared file storage system, some files may be deleted by mistake while the shared users use the shared files, so that certain safety problems are brought. Along with the increase of the number of sharing people, the probability of mistaken deletion of the file is also improved.
Disclosure of Invention
To overcome the problems in the related art, the present disclosure provides a method, an apparatus, a server, and a storage medium for preventing a file from being deleted by mistake.
According to a first aspect of the embodiments of the present disclosure, a method for preventing a file from being deleted by mistake is provided, which includes:
receiving a setting instruction of a sub item undeletable identifier, wherein the setting instruction of the sub item undeletable identifier comprises a directory of a sub item undeletable identifier to be set;
and setting a sub-item undeletable identifier for the index node of the directory according to the sub-item undeletable identifier setting instruction so as to prevent the first-level sub-item of the directory from being deleted by mistake.
Optionally, after setting the undeletable sub-entry identifier for the index node of the directory, the method further includes:
receiving a file deleting command, wherein the file deleting command comprises a storage path of a file to be deleted;
determining a parent directory of the file to be deleted according to the storage path;
acquiring an index node of the father directory according to the father directory;
and when the index node comprises a sub item undeletable identifier, stopping deleting the file to be deleted.
Optionally, the method further includes:
and deleting the file to be deleted when the index node does not contain the child item undeletable identification.
Optionally, the deleting the file to be deleted includes:
determining a directory entry of the file to be deleted according to the index node and the name of the file to be deleted;
determining an index node corresponding to the file to be deleted according to the directory entry;
deleting the file to be deleted and the information of the file to be deleted in the index node corresponding to the parent directory, and deleting the index node corresponding to the file to be deleted.
Optionally, the deleting the index node corresponding to the file to be deleted includes:
when the current CPU utilization rate exceeds a first set threshold value, setting a deletion identifier for the directory entry;
and when the CPU utilization rate is less than a second set threshold, deleting the index node corresponding to the file to be deleted according to the deletion identifier of the directory entry, wherein the first set threshold is greater than the second set threshold.
Optionally, after setting the undeletable sub-entry identifier for the index node of the directory, the method further includes:
receiving a cancellation instruction of a sub-item undeletable identifier of the directory;
according to the canceling instruction, canceling the undeletable sub-item identifier in the index node of the directory;
receiving a delete command for a first level child entry of the directory;
according to the deleting command, when the index node of the directory does not contain a sub-item undeletable identifier, deleting the first-level sub-item and the information of the first-level sub-item in the index node, and deleting the index node corresponding to the first-level sub-item.
Optionally, the child undeletable identifier is an extended attribute.
Optionally, the first level sub-item comprises a file or a folder.
According to a second aspect of the embodiments of the present disclosure, there is provided an apparatus for preventing a file from being deleted by mistake, including:
the setting instruction receiving module is configured to receive a setting instruction of the subitem undeletable identifier, wherein the setting instruction of the subitem undeletable identifier comprises a directory of the subitem undeletable identifier to be set;
and the undeletable identifier setting module is configured to set an undeletable identifier for the index node of the directory according to the undeletable identifier setting instruction of the sub-entry, so as to prevent the first-level sub-entry of the directory from being deleted by mistake.
The file deleting module is configured to delete a file to be deleted, and the file to be deleted comprises a storage path of a file to be deleted;
the parent directory determining module is configured to determine a parent directory of the file to be deleted according to the storage path;
the index node acquisition module is configured to acquire the index node of the parent directory according to the parent directory;
and the deletion stopping module is configured to stop deleting the file to be deleted when the index node contains a sub-item undeletable identifier.
Optionally, the method further includes:
the first deleting module is configured to delete the file to be deleted when the indexing node does not contain the child undeletable identifier.
Optionally, the first deleting module includes:
the directory entry determining unit is configured to determine a directory entry of the file to be deleted according to the index node and the name of the file to be deleted;
the index node determining unit is configured to determine an index node corresponding to the file to be deleted according to the directory entry;
and the deleting unit is configured to delete the file to be deleted and the information of the file to be deleted in the index node corresponding to the parent directory, and delete the index node corresponding to the file to be deleted.
Optionally, the deleting unit includes:
a deletion identifier setting subunit configured to set a deletion identifier for the directory entry when the current CPU utilization exceeds a first set threshold;
and the index node deleting subunit is configured to delete the index node corresponding to the file to be deleted according to the deletion identifier of the directory entry when the CPU utilization rate is smaller than a second set threshold, wherein the first set threshold is larger than the second set threshold.
Optionally, the apparatus further comprises:
a cancellation instruction receiving module configured to receive a cancellation instruction of a child undeletable identifier of the directory;
a non-deletable identifier canceling module configured to cancel the child non-deletable identifier in the index node of the directory according to the cancel instruction;
a sub item deletion command receiving module configured to receive a deletion command for a first level sub item of the directory;
and the second deleting module is configured to delete the first-level sub-item and the information of the first-level sub-item in the index node and delete the index node corresponding to the first-level sub-item when the index node of the directory does not contain a sub-item undeletable identifier according to the deletion command.
Optionally, the child undeletable identifier is an extended attribute.
Optionally, the first level sub-item comprises a file or a folder.
According to a third aspect of the embodiments of the present disclosure, there is provided a server, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
receiving a setting instruction of a sub item undeletable identifier, wherein the setting instruction of the sub item undeletable identifier comprises a directory of a sub item undeletable identifier to be set;
and setting a sub-item undeletable identifier for the index node of the directory according to the sub-item undeletable identifier setting instruction so as to prevent the first-level sub-item of the directory from being deleted by mistake.
After setting a sub-item undeletable identifier for the index node of the directory, the method further includes:
receiving a file deleting command, wherein the file deleting command comprises a storage path of a file to be deleted;
determining a parent directory of the file to be deleted according to the storage path;
acquiring an index node of the father directory according to the father directory;
and when the index node comprises a sub item undeletable identifier, stopping deleting the file to be deleted.
Further comprising:
and deleting the file to be deleted when the index node does not contain the child item undeletable identification.
The deleting the file to be deleted includes:
determining a directory entry of the file to be deleted according to the index node and the name of the file to be deleted;
determining an index node corresponding to the file to be deleted according to the directory entry;
deleting the file to be deleted and the information of the file to be deleted in the index node corresponding to the parent directory, and deleting the index node corresponding to the file to be deleted.
The deleting the index node corresponding to the file to be deleted includes:
when the current CPU utilization rate exceeds a first set threshold value, setting a deletion identifier for the directory entry;
and when the CPU utilization rate is less than a second set threshold, deleting the index node corresponding to the file to be deleted according to the deletion identifier of the directory entry, wherein the first set threshold is greater than the second set threshold.
After setting a sub-item undeletable identifier for the index node of the directory, the method further includes:
receiving a cancellation instruction of a sub-item undeletable identifier of the directory;
according to the canceling instruction, canceling the undeletable sub-item identifier in the index node of the directory;
receiving a delete command for a first level child entry of the directory;
according to the deleting command, when the index node of the directory does not contain a sub-item undeletable identifier, deleting the first-level sub-item and the information of the first-level sub-item in the index node, and deleting the index node corresponding to the first-level sub-item.
The child undeletable identifier is an extended attribute.
Optionally, the first level sub-item comprises a file or a folder.
According to a fourth aspect of embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium, wherein instructions of the storage medium, when executed by a processor of a mobile terminal, enable the mobile terminal to perform the method for preventing file deletion by mistake of the first aspect.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program, the method of which includes the steps of the method of preventing a file from being deleted by mistake in the first aspect.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: by receiving a sub-item undeletable identifier setting instruction which comprises a directory to be set with a sub-item undeletable identifier, and setting the sub-item undeletable identifier for an index node of the directory according to the sub-item undeletable identifier setting instruction, the first-level sub-item of the directory can be prevented from being deleted by mistake, the files in the network shared file storage system are effectively prevented from being deleted by mistake, and the safety of the files in the network shared file storage system is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a flow diagram illustrating a method of preventing file mischief according to an exemplary embodiment;
FIG. 2 is a flow diagram illustrating a method of preventing file mischief according to an example embodiment;
FIG. 3 is a flow diagram illustrating a method of preventing file mischief according to an example embodiment;
FIG. 4 is a flow diagram illustrating a method of preventing file mischief according to an example embodiment;
FIG. 5 is a block diagram illustrating an apparatus for preventing file deletion errors in accordance with an exemplary embodiment;
FIG. 6 is a block diagram illustrating the structure of a server in accordance with an exemplary embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
Fig. 1 is a flowchart illustrating a method for preventing a file from being deleted by mistake according to an exemplary embodiment, and the method for preventing a file from being deleted by mistake is used in a server, as shown in fig. 1, and includes the following steps.
In step S11, a sub item undeletable flag setting instruction including a directory in which a sub item undeletable flag is to be set is received.
In order to avoid that important files in the network shared file storage system are deleted by mistake, a first user can input a setting instruction of a sub-item undeletable identifier through a client of the network shared file storage system, the client sends the sub-item undeletable identifier to a server of the network shared file storage system, and the server can receive the setting instruction of the sub-item undeletable identifier of the first user. The first user can be a user with the setting authority of the identification that the sub item can not be deleted.
In step S12, according to the sub-item undeletable identifier setting instruction, a sub-item undeletable identifier is set for the inode of the directory to prevent the first-level sub-item of the directory from being deleted by mistake.
The index node (inode) is used to store the basic information of the files and directories, including time, file names, users and groups. The first level child items may be files or folders, and may also be directory files.
Files are stored on hard disks, and the smallest unit of storage of a hard disk is called a Sector (Sector). Each sector stores 512 bytes (equivalent to 0.5 KB). When the operating system reads the hard disk, a plurality of sectors are read continuously at one time, namely one block (block) is read at one time. Such a block, which is composed of a plurality of sectors, is the minimum unit of file access. File data is stored in blocks, and an area for storing file meta information, such as a creator of the file, a creation date of the file, a size of the file, and the like, is also required. Each file has a corresponding inode that contains some information about the file.
According to the sub item undeletable identification setting instruction, determining a directory which needs to set the sub item undeletable identification, and searching the index node corresponding to the directory according to the directory, thereby setting the sub item undeletable identification for the index node, wherein all first-level sub items of the directory corresponding to the index node cannot be deleted by mistake, and other-level sub items (such as second-level sub items and third-level sub items) of the directory are not influenced by the sub item undeletable identification. When a file or a folder needs to be deleted, a child item undeletable identifier is set in the index node of the parent directory, and if the child item undeletable identifier exists in the index node of the parent directory, the operation of deleting the file or the folder is not executed any more, so that the error deletion is avoided.
Where child undeletable identifiers are optionally extended attributes, extended attributes (xattrs) provide a mechanism to permanently associate "name/value" pairs to files, allowing existing file systems to support functionality not provided in the original design. The name is a common character string, and the value is not limited. The extended attribute is an attribute of the Linux system, and the embodiment of the disclosure sets the undeletable property of the child item by using the extended attribute, so that introduction of new data can be avoided, and the implementation is easy.
In the method for preventing a file from being deleted by mistake provided by the present exemplary embodiment, a sub item undeletable identifier setting instruction is received, where the sub item undeletable identifier setting instruction includes a directory to be set with a sub item undeletable identifier, and a sub item undeletable identifier is set for an index node of the directory according to the sub item undeletable identifier setting instruction, so that a first-level sub item of the directory can be prevented from being deleted by mistake, a file in a network shared file storage system is effectively prevented from being deleted by mistake, and the security of the file in the network shared file storage system is improved.
Fig. 2 is a flowchart illustrating a method for preventing a file from being deleted by mistake according to an exemplary embodiment, and as shown in fig. 2, the method includes the following steps.
In step S21, a sub item undeletable flag setting instruction including a directory in which a sub item undeletable flag is to be set is received.
The specific content of this step is the same as that of step S11 in the above exemplary embodiment, and is not described here again.
In step S22, according to the sub-item undeletable identifier setting instruction, a sub-item undeletable identifier is set for the inode of the directory to prevent the first-level sub-item of the directory from being deleted by mistake.
The specific content of this step is the same as that of step S12 in the above exemplary embodiment, and is not described here again.
In step S23, a file deletion command is received, the file deletion command including a storage path of a file to be deleted.
A user can designate a file to be deleted through a client of the network shared file storage system, the client determines a storage path of the file to be deleted according to the operation of the user, generates a file deletion command and sends the file deletion command to a server of the network shared file storage system. The server receives a file deleting command sent by the client, and determines a storage path of a file to be deleted according to the file deleting command. The user may be the aforementioned first user, or may be another user.
In step S24, the parent directory of the file to be deleted is determined according to the storage path.
The parent directory is a previous-level directory of the current position, and the parent directory of the file to be deleted is a previous-level directory of the file to be deleted.
For example, the name of the file to be deleted is file, the storage path of the file to be deleted is dira/file, and the parent directory of the file to be deleted is dira.
In step S25, according to the parent directory, an index node of the parent directory is obtained.
Each directory in the storage path corresponds to a file or a folder, and each file or folder has a corresponding index node, so that the index node corresponding to the parent directory can be acquired according to the parent directory.
In step S26, when the inode includes a child undeletable identifier, the deletion of the file to be deleted is stopped.
The embodiment of the disclosure sets the undeletable property of the child item by setting the undeletable identifier of the child item in the index node of the parent directory, so that, when the index node corresponding to the parent directory contains the undeletable identifier of the child item, the first-level child item of the parent directory is undeletable, that is, the operation of deleting the file to be deleted is not performed, that is, the deletion of the file to be deleted is stopped.
For example, in the file to be deleted is dir1, the storage path is dir111/dir11/dir1/file2, if the index node of the parent directory dir11 of the dir1 contains the extended attribute, the first-level child entry of the parent directory dir11 cannot be deleted, the dir1 cannot be deleted, and if the child entry of the dir11 further includes dir2, the dir2 cannot be deleted. When an index node of dir11 contains an extended attribute, deletion of a second-level child item is not affected, that is, deletion of file2 is not affected, when file2 is to be deleted, whether the index node of dir1 contains the extended attribute needs to be detected, if the index node of dir1 contains the extended attribute, file2 cannot be deleted, and if the index node of dir1 does not contain the extended attribute, file2 can be deleted.
According to the method for preventing the file from being deleted by mistake, the file deleting command is received, the file deleting command comprises the storage path of the file to be deleted, the parent directory of the file to be deleted is determined according to the storage path, the index node corresponding to the parent directory is determined, when the index node comprises the child undeletable identifier, the file to be deleted is stopped being deleted, whether the index node corresponding to the parent directory comprises the child undeletable identifier or not is detected, the file is prevented from being deleted by mistake, the file in the network shared file storage system is effectively prevented from being deleted by mistake, and the safety of the file in the network shared file storage system is improved.
Fig. 3 is a flowchart illustrating a method of preventing a file from being deleted by mistake according to an exemplary embodiment, as shown in fig. 2, the method including the following steps.
In step S31, a sub item undeletable flag setting instruction including a directory in which a sub item undeletable flag is to be set is received.
The specific content of this step is the same as the specific content of step S11 in the above exemplary embodiment, and is not described here again.
In step S32, according to the sub-item undeletable identifier setting instruction, a sub-item undeletable identifier is set for the inode of the directory to prevent the first-level sub-item of the directory from being deleted by mistake.
The specific content of this step is the same as that of step S12 in the above exemplary embodiment, and is not described here again.
In step S33, a file deletion command is received, the file deletion command including a storage path of a file to be deleted.
The specific content of this step is the same as that of step S23 in the above exemplary embodiment, and is not described here again.
In step S34, the parent directory of the file to be deleted is determined according to the storage path.
The specific content of this step is the same as that of step S34 in the above exemplary embodiment, and is not described here again.
In step S35, according to the parent directory, an index node of the parent directory is obtained.
The specific content of this step is the same as that of step S35 in the above exemplary embodiment, and is not described here again.
In step S36, when a child undeletable identifier is included in the inode, deleting the file to be deleted is stopped.
The specific content of this step is the same as that of step S36 in the above exemplary embodiment, and is not described here again.
In step S37, when the inode does not include the child undeletable identifier, the file to be deleted is deleted.
The method and the device for deleting the file to be deleted identify whether the child item of the parent directory has the undeletable characteristic or not by judging whether the index node corresponding to the parent directory contains the undeletable identifier or not, and execute the operation of deleting the file to be deleted if the child item of the parent directory does not have the undeletable characteristic when the index node corresponding to the parent directory does not contain the undeletable identifier of the child item.
Optionally, the deleting the file to be deleted includes:
determining a directory entry of the file to be deleted according to the index node and the name of the file to be deleted;
determining an index node corresponding to the file to be deleted according to the directory entry;
deleting the file to be deleted and the information of the file to be deleted in the index node corresponding to the parent directory, and deleting the index node corresponding to the file to be deleted.
Wherein, the directory entry (entry) is a link of a certain index node (inode) in the Linux file system. This inode may be file or directory.
The metadata information of the file to be deleted is stored in the index node of the parent directory, so that the directory entry of the file to be deleted is inquired in the index node of the parent directory of the file to be deleted according to the name of the file to be deleted, and because the directory entry of the file to be deleted points to the index node of the file to be deleted, the index node corresponding to the file to be deleted can be positioned according to the directory entry of the file to be deleted, the index node is deleted, and the file to be deleted and the metadata information of the file to be deleted in the index node corresponding to the parent directory of the file to be deleted are deleted.
Optionally, the deleting the index node corresponding to the file to be deleted includes:
when the current CPU utilization rate exceeds a first set threshold value, setting a deletion identifier for the directory entry;
and when the CPU utilization rate is less than a second set threshold, deleting the index node corresponding to the file to be deleted according to the deletion identifier of the directory entry, wherein the first set threshold is greater than the second set threshold.
The CPU is in a busy state when the CPU utilization exceeds the first set threshold, the CPU utilization is less than the second set threshold, the CPU is in an idle state, the first set threshold is greater than the second set threshold, and if the first set threshold may be 70% and the second set threshold may be 30%. The deletion identifier is used for identifying delayed deletion.
Because the deletion of the index node needs to consume a large amount of CPU, if the current CPU is in a busy state when the file to be deleted is to be deleted, a deletion identifier can be set for the directory entry corresponding to the file to be deleted, the directory entry with the deletion identifier and the corresponding index node are associated, and when the CPU is idle, the index node associated with the directory entry with the deletion identifier is deleted from the hard disk. By delaying deletion, the problem that the user request cannot be responded in time due to the fact that the deleted file occupies a large amount of CPU can be avoided.
In the method for preventing a file from being deleted by mistake provided by the present exemplary embodiment, when the index node of the parent directory of the file to be deleted includes the child undeletable identifier, the deletion of the file to be deleted is stopped, and when the index node of the parent directory of the file to be deleted does not include the child undeletable identifier, the file to be deleted is deleted, so that the file in the network shared file storage system is effectively prevented from being deleted by mistake, and the security of the file in the network shared file storage system is improved.
Fig. 4 is a flowchart illustrating a method of preventing a file from being deleted by mistake according to an exemplary embodiment, and as shown in fig. 4, the method includes the following steps.
In step S41, a sub item undeletable flag setting instruction including a directory in which a sub item undeletable flag is to be set is received.
The specific content of this step is the same as that of step S11 in the above exemplary embodiment, and is not described here again.
In step S42, according to the sub-item undeletable identifier setting instruction, a sub-item undeletable identifier is set for the inode of the directory to prevent the first-level sub-item of the directory from being deleted by mistake.
The specific content of this step is the same as the specific content of step S12 in the above exemplary embodiment, and is not described here again.
In step S43, a cancel instruction for a child undeletable flag possessed by the directory is received.
If the second user does want to delete the first-level child item under the directory, it is first necessary to cancel the undeletable property of the first-level child item, that is, delete the undeletable identifier of the child item of the parent directory, so that the user may input a cancel instruction for the undeletable identifier of the child item of the directory through the client of the network-shared file storage system, and the client of the network-shared file storage system sends the cancel instruction to the server of the network-shared file storage system. The second user may be a user outside the first user, or may be the first user.
In step S44, according to the cancel instruction, the child undeletable flag is canceled in the index node of the directory.
The server of the network-shared file storage system may determine whether the second user has a cancellation authority of the child non-deletable identifier according to the identifier of the second user. When the second user has the cancellation right, the undeletable sub-item identifier is cancelled in the index node of the directory, so that the second user or other users can delete the first-level sub-item of the directory after canceling the undeletable sub-item identifier. And if the second user inputs a deletion command for the first-level sub-item of the directory, the server determines that the index node of the directory does not contain the non-deletable sub-item identifier, and deletes the first-level sub-item.
In step S45, a delete command is received for a first level child of the directory.
In step S46, according to the deletion command, when it is determined that the index node of the directory does not include a child undeletable identifier, deleting the first-level child item and the information of the first-level child item in the index node, and deleting the index node corresponding to the first-level child item.
When a deletion command of a second user for a first-level sub-item of a directory is received, firstly, whether a sub-item undeletable identifier is contained in an index node of the directory is determined, if the sub-item undeletable identifier is not contained, information of the first-level sub-item and the first-level sub-item in the index node of the directory is deleted, and the index node corresponding to the first-level sub-item is deleted. When deleting the index node corresponding to the first-level sub-item, the directory item of the first-level sub-item may be determined according to the index node of the directory and the name of the first-level sub-item, the index node corresponding to the first-level sub-item may be determined according to the directory item, and the index node corresponding to the first-level sub-item may be deleted. If the current CPU utilization rate exceeds a first set threshold value when the index node corresponding to the first-level sub-item is deleted, a deletion identifier is set for the directory item of the first-level sub-item, and when the CPU utilization rate is smaller than a second set threshold value, the index node corresponding to the first-level sub-item is deleted according to the deletion identifier of the directory item; and if the current CPU utilization rate does not exceed the first set threshold value when the index node corresponding to the first-level sub-item is deleted, deleting the index node corresponding to the first-level sub-item. Wherein the first set threshold is greater than the second set threshold.
Based on the foregoing exemplary embodiment, in the method for preventing a file from being deleted by mistake provided by this exemplary embodiment, by receiving a cancel instruction for a sub-item undeletable identifier of the directory, canceling the sub-item undeletable identifier in an index node of the directory according to the cancel instruction, and when receiving a delete command for a first-level sub-item of the directory, deleting information of the first-level sub-item and the first-level sub-item in the index node of the directory, and deleting an index node corresponding to the first-level sub-item, a delete manner for the first-level sub-item provided with the sub-item undeletable identifier is implemented, and first, a sub-item undeletable characteristic corresponding to the first-level sub-item needs to be cancelled, so as to avoid file deletion by mistake.
Fig. 5 is a block diagram illustrating a structure of an apparatus for preventing a file from being deleted by mistake according to an exemplary embodiment. Referring to fig. 5, the apparatus includes a setting instruction receiving module 51 and a non-deletable flag setting module 52.
The setting instruction receiving module 51 is configured to receive a sub item undeletable identifier setting instruction including a directory in which a sub item undeletable identifier is to be set;
the undeletable identifier setting module 52 is configured to set a subitem undeletable identifier for the index node of the directory according to the subitem undeletable identifier setting instruction, so as to prevent the first-level subitem of the directory from being deleted by mistake.
The deletion command receiving module is configured to receive a file deletion command after setting a sub-item undeletable identifier for an inode of the directory, wherein the file deletion command comprises a storage path of a file to be deleted;
the parent directory determining module is configured to determine a parent directory of the file to be deleted according to the storage path;
the index node acquisition module is configured to acquire the index node of the parent directory according to the parent directory;
and the deletion stopping module is configured to stop deleting the file to be deleted when the index node contains a sub-item undeletable identifier.
Optionally, the method further includes:
the first deleting module is configured to delete the file to be deleted when the indexing node does not contain the child undeletable identifier.
Optionally, the first deleting module includes:
the directory entry determining unit is configured to determine a directory entry of the file to be deleted according to the index node and the name of the file to be deleted;
the index node determining unit is configured to determine an index node corresponding to the file to be deleted according to the directory entry;
and the deleting unit is configured to delete the file to be deleted and the information of the file to be deleted in the index node corresponding to the parent directory, and delete the index node corresponding to the file to be deleted.
Optionally, the deleting unit includes:
a deletion identifier setting subunit configured to set a deletion identifier for the directory entry when the CPU utilization exceeds a first set threshold;
and the index node deleting subunit is configured to delete the index node corresponding to the file to be deleted according to the deletion identifier of the directory entry when the CPU utilization rate is smaller than a second set threshold, wherein the first set threshold is larger than the second set threshold.
Optionally, the apparatus further comprises:
a cancellation instruction receiving module configured to receive a cancellation instruction of a child undeletable identifier of the directory;
a non-deletable identifier canceling module configured to cancel the child non-deletable identifier in the index node of the directory according to the cancel instruction;
a sub item deletion command receiving module configured to receive a deletion command for a first level sub item of the directory;
and the second deleting module is configured to delete the first-level sub-item and the information of the first-level sub-item in the index node and delete the index node corresponding to the first-level sub-item when the index node of the directory does not contain a sub-item undeletable identifier according to the deletion command.
Optionally, the child undeletable identifier is an extended attribute.
Optionally, the first level sub-item comprises a file or a folder.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 6 is a block diagram illustrating the structure of a server in accordance with an exemplary embodiment. Referring to fig. 6, server 600 includes a processing component 622 that further includes one or more processors and memory resources, represented by memory 632, for storing instructions, such as applications, that are executable by processing component 622. The application programs stored in memory 632 may include one or more modules that each correspond to a set of instructions. Further, the processing component 622 is configured to execute instructions to perform the above-described methods.
The server 600 may also include a power component 626 configured to perform power management of the server 600, a wired or wireless network interface 650 configured to connect the server 600 to a network, and an input/output (I/O) interface 658. The server 600 may operate based on an operating system stored in memory 632, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
Memory 632 is configured to store various types of data to support operations at server 600. Examples of such data include instructions for any application or method operating on server 600. The memory 632 may be implemented by any type or combination of volatile or non-volatile storage devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 626 provides power to the various components of the server 600. The power components 626 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the server 600.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided that includes instructions, such as the memory 632 that includes instructions, that are executable by the processing component 622 of the server 600 to perform the above-described methods. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer program is also provided that includes one or more instructions executable by the processing component 622 of the server 600 to perform the above-described method of preventing file deletion errors.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (12)

1. A method for preventing file deletion errors, for use in a network-shared file storage system, the method comprising:
receiving a file deleting command, wherein the file deleting command comprises a storage path of a file to be deleted;
determining a parent directory of the file to be deleted according to the storage path;
acquiring an index node of the father directory according to the father directory;
when the index node comprises a sub item undeletable identifier, stopping deleting the file to be deleted; when the index node of the parent directory contains the identification that the child item cannot be deleted, the first-level child item of the parent directory cannot be deleted;
wherein the sub-item undeletable identifier is set by: receiving a setting instruction of a sub item undeletable identifier, wherein the setting instruction of the sub item undeletable identifier comprises a directory of a sub item undeletable identifier to be set; setting a sub-item undeletable identifier for an index node of the directory according to the sub-item undeletable identifier setting instruction, so as to prevent all first-level sub-items of the directory from being deleted by mistake, and prevent other-level sub-items of the directory from being influenced by the sub-item undeletable identifier;
when the index node does not contain the child undeletable identifier, deleting the index node corresponding to the file to be deleted, wherein the deleting the index node corresponding to the file to be deleted comprises: when the current CPU utilization rate exceeds a first set threshold value, setting a deletion identifier for the directory entry; and when the CPU utilization rate is less than a second set threshold, deleting the index node corresponding to the file to be deleted according to the deletion identifier of the directory entry, wherein the first set threshold is greater than the second set threshold.
2. The method according to claim 1, wherein the deleting the file to be deleted comprises:
determining a directory entry of the file to be deleted according to the index node and the name of the file to be deleted;
determining an index node corresponding to the file to be deleted according to the directory entry;
deleting the file to be deleted and the information of the file to be deleted in the index node corresponding to the parent directory, and deleting the index node corresponding to the file to be deleted.
3. The method according to claim 1, further comprising, after setting a child undeletable identifier for an inode of the directory:
receiving a cancellation instruction of a sub-item undeletable identifier of the directory;
according to the canceling instruction, canceling the undeletable sub-item identifier in the index node of the directory;
receiving a delete command for a first level child entry of the directory;
according to the deleting command, when the index node of the directory does not contain a sub-item undeletable identifier, deleting the first-level sub-item and the information of the first-level sub-item in the index node, and deleting the index node corresponding to the first-level sub-item.
4. The method of any of claims 1-3, wherein the child undeletable identifier is an extended attribute.
5. The method of any of claims 1-3, wherein the first level sub-item comprises a file or folder.
6. An apparatus for preventing file deletion errors, used in a network-shared file storage system, comprising:
the file deleting method comprises a deleting command receiving module, a deleting command sending module and a deleting module, wherein the deleting command receiving module is configured to receive a file deleting command after setting a sub item undeletable identifier for an index node of a directory, and the file deleting command comprises a storage path of a file to be deleted;
the parent directory determining module is configured to determine a parent directory of the file to be deleted according to the storage path;
the index node acquisition module is configured to acquire the index node of the parent directory according to the parent directory;
the deletion stopping module is configured to stop deleting the file to be deleted when the index node contains a sub-item undeletable identifier; when the index node of the parent directory contains the identification that the child item cannot be deleted, the first-level child item of the parent directory cannot be deleted;
the setting instruction receiving module is configured to receive a sub item undeletable identifier setting instruction, and the sub item undeletable identifier setting instruction comprises a directory of sub item undeletable identifiers to be set;
the undeletable identifier setting module is configured to set an undeletable identifier for the index node of the directory according to the undeletable identifier setting instruction of the sub-entry, so as to prevent all first-level sub-entries of the directory from being deleted by mistake; while other level child items of the directory are not affected by the child item undeletable identification;
the device is also used for receiving a file deleting command, and deleting the file to be deleted when the index node does not contain the child undeletable identifier; the deleting the file to be deleted includes: deleting the index node corresponding to the file to be deleted; the deleting the index node corresponding to the file to be deleted includes: when the current CPU utilization rate exceeds a first set threshold value, setting a deletion identifier for the directory entry; and when the CPU utilization rate is less than a second set threshold, deleting the index node corresponding to the file to be deleted according to the deletion identifier of the directory entry, wherein the first set threshold is greater than the second set threshold.
7. The apparatus of claim 6, further comprising a first deletion module, the first deletion module comprising:
the directory entry determining unit is configured to determine a directory entry of the file to be deleted according to the index node and the name of the file to be deleted;
the index node determining unit is configured to determine an index node corresponding to the file to be deleted according to the directory entry;
and the deleting unit is configured to delete the file to be deleted and the information of the file to be deleted in the index node corresponding to the parent directory, and delete the index node corresponding to the file to be deleted.
8. The apparatus of claim 7, further comprising:
a cancellation instruction receiving module configured to receive a cancellation instruction of a child undeletable identifier of the directory;
a non-deletable identifier canceling module configured to cancel the child non-deletable identifier in the index node of the directory according to the cancel instruction;
a sub item deletion command receiving module configured to receive a deletion command for a first level sub item of the directory;
and the second deleting module is configured to delete the first-level sub-item and the information of the first-level sub-item in the index node and delete the index node corresponding to the first-level sub-item when the index node of the directory does not contain a sub-item undeletable identifier according to the deletion command.
9. The apparatus of any of claims 6-8, wherein the child undeletable identifier is an extended attribute.
10. The apparatus of any of claims 6-8, wherein the first level sub-item comprises a file or folder.
11. A server, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the method of preventing file misdeletion according to any one of claims 1 to 5.
12. A non-transitory computer readable storage medium, wherein instructions in the storage medium, when executed by a processor of a mobile terminal, enable the mobile terminal to implement the method for preventing file deletion errors as claimed in any one of claims 1 to 5.
CN201811556213.7A 2018-12-19 2018-12-19 Method, device, server and storage medium for preventing file from being deleted by mistake Active CN109828962B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811556213.7A CN109828962B (en) 2018-12-19 2018-12-19 Method, device, server and storage medium for preventing file from being deleted by mistake

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811556213.7A CN109828962B (en) 2018-12-19 2018-12-19 Method, device, server and storage medium for preventing file from being deleted by mistake

Publications (2)

Publication Number Publication Date
CN109828962A CN109828962A (en) 2019-05-31
CN109828962B true CN109828962B (en) 2022-06-24

Family

ID=66859651

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811556213.7A Active CN109828962B (en) 2018-12-19 2018-12-19 Method, device, server and storage medium for preventing file from being deleted by mistake

Country Status (1)

Country Link
CN (1) CN109828962B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8924664B2 (en) * 2012-12-13 2014-12-30 Infinidat Ltd. Logical object deletion
CN104573093A (en) * 2015-01-29 2015-04-29 广东欧珀移动通信有限公司 Method and device for managing file catalog
CN106354884A (en) * 2016-10-09 2017-01-25 郑州云海信息技术有限公司 Data object deleting method and device based on distributed file system
CN106709034A (en) * 2016-12-29 2017-05-24 广东欧珀移动通信有限公司 File protection method and apparatus, and terminal
CN107609027A (en) * 2017-08-08 2018-01-19 捷开通讯(深圳)有限公司 The anti-deleted marker position of file is set and prevents from deleting the method and device of file by mistake

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8924664B2 (en) * 2012-12-13 2014-12-30 Infinidat Ltd. Logical object deletion
CN104573093A (en) * 2015-01-29 2015-04-29 广东欧珀移动通信有限公司 Method and device for managing file catalog
CN106354884A (en) * 2016-10-09 2017-01-25 郑州云海信息技术有限公司 Data object deleting method and device based on distributed file system
CN106709034A (en) * 2016-12-29 2017-05-24 广东欧珀移动通信有限公司 File protection method and apparatus, and terminal
CN107609027A (en) * 2017-08-08 2018-01-19 捷开通讯(深圳)有限公司 The anti-deleted marker position of file is set and prevents from deleting the method and device of file by mistake

Also Published As

Publication number Publication date
CN109828962A (en) 2019-05-31

Similar Documents

Publication Publication Date Title
US20160292445A1 (en) Context-based data classification
US6449615B1 (en) Method and system for maintaining the integrity of links in a computer network
CN109739815B (en) File processing method, system, device, equipment and storage medium
US11403027B2 (en) Technology for governance of data retention and transfer
US20020065835A1 (en) File system assigning a specific attribute to a file, a file management method assigning a specific attribute to a file, and a storage medium on which is recorded a program for managing files
US9292387B2 (en) Medium, control method, and information processing apparatus
US20050131902A1 (en) File system and file transfer method between file sharing devices
US9864736B2 (en) Information processing apparatus, control method, and recording medium
CN111181975B (en) Account management method, device, equipment and storage medium
US8321487B1 (en) Recovery of directory information
CN108021590B (en) Target object attribute determining method, attribute updating method and device
CN105824827A (en) File path storage and local file visiting method and apparatus
US8583662B2 (en) Managing data across a plurality of data storage devices based upon collaboration relevance
CN111240892A (en) Data backup method and device
CN114629921A (en) Cloud platform and bucket management method of object storage service provided by cloud platform
CN111652685A (en) Information processing method, information processing device, computer equipment and computer readable storage medium
CN109344650A (en) A kind of file permission management method, system and the relevant apparatus of file system
CN109828962B (en) Method, device, server and storage medium for preventing file from being deleted by mistake
US20160004850A1 (en) Secure download from internet marketplace
US11822806B2 (en) Using a secondary storage system to implement a hierarchical storage management plan
CN113076086B (en) Metadata management system and method for modeling model object using the same
CN112583761B (en) Management method and device of security entity, computer equipment and storage medium
CN109241011B (en) Virtual machine file processing method and device
CN112596959A (en) Distributed storage cluster data backup method and device
CN110888847A (en) Recycle bin system and file recycling method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant