CN117251417A - File copying method and device, electronic equipment and storage medium - Google Patents

File copying method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117251417A
CN117251417A CN202310622976.1A CN202310622976A CN117251417A CN 117251417 A CN117251417 A CN 117251417A CN 202310622976 A CN202310622976 A CN 202310622976A CN 117251417 A CN117251417 A CN 117251417A
Authority
CN
China
Prior art keywords
folder
task
target
copying
state
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.)
Pending
Application number
CN202310622976.1A
Other languages
Chinese (zh)
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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202310622976.1A priority Critical patent/CN117251417A/en
Publication of CN117251417A publication Critical patent/CN117251417A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • G06F16/184Distributed file systems implemented as replicated file system

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a folder copying method, relates to the technical field of data processing, and particularly relates to a folder copying device, electronic equipment and a storage medium. The specific implementation scheme is as follows: creating a folder replication task in response to a folder replication request; creating a target folder corresponding to the source folder at a target position matched with the folder replication request, and creating a pointing relation pointed to the source folder by the target folder on the target folder, wherein the pointing relation is used for pointing the operation of a user aiming at the target folder to the source folder; and executing a folder copying task, copying the files in the source folder into the target folder, and canceling the pointing relation after copying is completed. The method and the device can ensure the availability of the file in the copying process and avoid the occupation of the file in the copying process.

Description

File copying method and device, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of data processing, and in particular relates to a method and a device for copying folders, electronic equipment and a storage medium.
Background
With the development of cloud storage technology, cloud space provides cloud storage service with ultra-large space for users, so when users copy folders in the cloud space, the folders generally contain millions of full files, which causes the whole operation process to take longer time and has higher delay; in the process of copying the folders, in order to smoothly perform the copying task, the files in the target folders are usually locked, i.e. the files cannot be operated, so that the time taken for the files is long, and the user cannot use the files.
Disclosure of Invention
The present disclosure provides a folder copying method, apparatus, electronic device, and storage medium for solving at least one of the above technical problems.
According to an aspect of the present disclosure, there is provided a folder replication method, the method including:
creating a folder replication task in response to a folder replication request;
creating a target folder corresponding to the source folder at a target position matched with the folder replication request, and creating a pointing relation pointed to the source folder by the target folder on the target folder, wherein the pointing relation is used for pointing the operation of a user on the target folder to the source folder;
and executing the folder copying task, copying the files in the source folder into the target folder, and canceling the pointing relationship after copying is completed.
According to another aspect of the present disclosure, there is provided a copying apparatus of a folder, the apparatus including:
the task creation module is used for responding to the folder copying request and creating a folder copying task;
the pointing relation creation module is used for creating a target folder corresponding to the source folder at a target position matched with the folder replication request, creating a pointing relation pointed to the source folder by the target folder on the target folder, and pointing the operation of a user on the target folder to the source folder;
And the task execution module is used for executing the folder copying task, copying the files in the source folder into the target folder, and canceling the pointing relationship after the copying is completed.
According to another aspect of the present disclosure, there is provided an electronic device including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the folder replication method described above.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform a copying method according to the above-described folder.
According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements a replication method according to the above-mentioned folder.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a flowchart of a method for copying folders provided in a first embodiment of the present disclosure;
FIG. 2 is a flowchart of a method for copying folders provided in a second embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating steps for protecting a copy file in a folder copy method provided by the present disclosure;
fig. 4 is a schematic structural view of a copying apparatus of a folder provided in a third embodiment of the present disclosure;
fig. 5 is a block diagram of an electronic device used to implement the methods of embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Embodiments of the disclosure and features of embodiments may be combined with each other without conflict.
As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used herein, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The method for copying the folder of the vehicle security asset according to the present disclosure may be performed by an electronic device such as a terminal device or a server, and the terminal device may be a vehicle-mounted device, a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a personal digital assistant (PersonalDigitalAssistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, or the like, and the method may be implemented by a processor invoking computer readable program instructions stored in a memory. Alternatively, the vehicle-mounted voice interaction method provided by the present disclosure may be executed by a server.
Note that, the method for copying the folder provided in the present disclosure may be executed in a storage server (e.g., cloud), or may be executed in a local storage unit, which is not limited herein.
In disclosing a first embodiment, referring to fig. 1, fig. 1 shows a flowchart of a folder copying method provided in the first embodiment of the present disclosure. The method comprises the following steps:
s101, responding to a folder copying request, and creating a folder copying task.
The folder replication request at least comprises task information, and the task information in the folder replication request at least comprises: the source folder, i.e. the folder to be copied, the target folder (targetfolder), i.e. the target folder into which the file is copied, may also include information such as a task identity (UserIdentification, UID), a task type (e.g. folder copy type), etc.
In addition, in order to obtain the information related to the task execution, a preset parameter item may be added to the task information, where the preset parameter item includes, for example: operation time (time elapsed to execute a task) and task status. And then, task identification (task ID) is distributed to the folder replication task, operation time and task state are added in task information, an association relation between the task identification and the task information is established, and the task identification, the task information and the association relation between the task identification and the task information are recorded into a preset task database table so as to facilitate subsequent inquiry of execution related information of the folder replication task from the task database table.
The task identification of the folder replication task is globally unique identification, and in the whole replication process, the folder replication task only has one task identification, and the task information and the task identification are bound and stored in a task database table, so that the required task information can be called through the task identification.
S102, creating a target folder corresponding to the source folder at a target position matched with the folder replication request, and creating a pointing relation pointed to the source folder by the target folder on the target folder.
The present method describes a copying process of copying a file in a source folder to a target folder, and the target location in S102 is a location selected by the user as a location where a newly copied folder (target folder) is stored.
Wherein the pointing relationship is used to point a user's operation with respect to the target folder to the source folder.
Further, in some examples, the pointing relationship is represented as a soft link. Creating a pointing relationship on the target folder, pointed to by the target folder as the source folder in S102, specifically includes:
a soft link is created on the target folder from the target folder to the source folder.
Wherein the soft link is a symbol link (symbol link), the soft link contains path information to the pointed object (source folder), and deleting the soft link does not affect the pointed folder.
In this way, when the folder replication task is initiated, a target folder corresponding to the replication completion state is created at a target position, and the target folder is linked into the source folder, so that in the process of executing the folder replication task, if a user wants to view a file in replication in the target folder, in other words, the user performs a file operation on the target folder, the user can point the file operation to the source file, call the target file corresponding to the file operation through the source file, and provide the file operation for the user to view.
S103, executing a folder copying task, copying files in the source folder into the target folder, and canceling the pointing relation after copying is completed.
By creating the target folder with the pointing relation pointing to the source folder in this way, the user can jump to the source folder to check the files to be copied through the target folder in the process of executing the folder copying task, thereby ensuring the usability of the files and avoiding the occupation of the files in the copying process.
In disclosing the second embodiment, referring to fig. 2, fig. 2 shows a flowchart of a folder copying method provided by the second embodiment of the present disclosure. The method comprises the following steps:
S201, responding to the folder copying request, and generating a folder copying task according to task information contained in the folder copying request.
Wherein, the task information at least comprises: the source folder and the target folder can also comprise information such as task identity marks, task types and the like. The task identity is a UID corresponding to a folder copying operation included in the folder copying request, the task type is, for example, a folder copying type, the source file is a folder to be copied, and the target folder is a target folder in which the file is copied in the task.
S202, task identification is allocated to the folder copying task, operation time and task state are added to the task information, and an association relation between the task identification and the task information is established.
The task state is one of a task initial state (i.e., a state when the file folder is just generated to copy the task and is not yet executed), a task in-process state, a task execution failure state, and a task execution completion state (all task execution completion states).
S203, recording the task identification, the task information and the association relation of the task identification and the task information into a preset task database table.
In order to obtain the information related to the task execution, a preset parameter item may be added to the task information, where the preset parameter item includes, for example: operation time (time elapsed to execute a task) and task status. And then, task identification is distributed to the folder replication task, operation time and task state are added in the task information, and the task identification and the task information are bound, in other words, an association relation between the task identification and the task information is established, and the task identification, the task information and the association relation between the task identification and the task information are recorded in a preset task database table so as to facilitate subsequent inquiry of the execution related information of the folder replication task from the task database table.
The task identification of the folder replication task is globally unique identification, and in the whole replication process, the folder replication task only has one task identification, and the task information and the task identification are bound and stored in a task database table, so that the required task information can be called through the task identification.
S201-S203 are one implementation of S101, specifically, S101 has other implementations, which are not limited herein.
S204, creating a target folder corresponding to the source folder at a target position matched with the folder replication request, and creating a pointing relation pointed to the source folder by the target folder on the target folder.
Wherein the pointing relationship is used to point a user's operation with respect to the target folder to the source folder.
Further, in some examples, the pointing relationship is represented as a soft link. Creating a pointing relationship on the target folder, pointed to by the target folder as the source folder in S102, specifically includes:
a soft link is created on the target folder from the target folder to the source folder.
Wherein the soft link is a symbol link (symbol link), the soft link contains path information to the pointed object (source folder), and deleting the soft link does not affect the pointed folder.
In this way, when the folder replication task is initiated, a target folder corresponding to the replication completion state is created at a target position, and the target folder is linked into the source folder, so that in the process of executing the folder replication task, if a user wants to view a file in replication in the target folder, in other words, the user performs a file operation on the target folder, the user can point the file operation to the source file, call the target file corresponding to the file operation through the source file, and provide the file operation for the user to view.
S205, the folder state of the target folder is set to the copy incomplete state.
Wherein the folder state is one of a copy incomplete state and a copy complete state. After creating the folder replication task, the folder state of the target folder is expressed as a replication incomplete state, the task state of the folder replication task is regularly detected according to a preset period in the task execution process, and the folder state of the target folder is modified into a replication complete state when the task execution complete state (all task execution complete states) is detected.
The duration of the preset period may be arbitrarily set according to a specific implementation manner, for example, set to 10ms.
In some examples, after S205, the method for copying folders provided by the present disclosure further includes:
step one: in response to a file view operation for any of the target folder, any of the files in the target folder, a folder state of the target folder is determined.
Step two: and under the condition that the folder state is determined to be in a copying incomplete state, pointing the file viewing operation to the source folder according to the pointing relation, and determining a target file corresponding to the file viewing operation in the source folder.
Step three: and executing file viewing operation on the target file.
In the embodiment of setting the folder state of the target folder, if a file checking operation that an execution object is the target folder or any file in the target folder and is sent by a user is received, namely, if the copying task of the current folder is completed through the folder state or not, and if the copying task is not completed (namely, the folder state is a copying incompletion state), the folder is jumped through the pointing relation, the target file matched in the folder by the file checking operation is determined, and the file checking operation is executed for the target file; and under the condition that the execution of the copying task is completed (namely, the folder state is the copying completion state), directly checking the file corresponding to the file checking operation through the target folder. In this way, the completion condition of the folder copying task can be determined directly through the folder state without calling a task database table to query the task state, so that the data processing amount can be reduced.
It should be noted that, the first step-the third step may be performed at any period after S204, and the execution order is not limited herein.
S206, dividing the plurality of sub-file objects contained in the source folder into a plurality of object groups.
S207, generating a plurality of asynchronous folder replication subtasks for a plurality of object groups respectively.
In the case where the number of subfile objects (which may be at least one of subfolders, files) included in the source folder is large (e.g., millions), the multiple subfile objects may be divided into multiple object groups, with one asynchronous folder replication sub-task being generated for each object group.
S208, sequentially executing a plurality of asynchronous folder replication subtasks, and updating task states of the folder replication tasks in the task database table according to the execution progress.
And generating an execution queue according to the plurality of asynchronous folder replication sub-tasks, sequentially executing the plurality of asynchronous folder replication sub-tasks according to the order of the execution queue and the mode of asynchronous tasks, and reducing the occurrence of task blocking and improving the reliability of task execution by a mode of batch replication.
And, in the process of executing the plurality of asynchronous folder replication subtasks, updating the task state of the folder replication tasks in the task database table according to the execution progress, specifically, S208 includes executing in any one of the following manners:
Mode one: and sequentially executing a plurality of asynchronous folder replication subtasks, and changing the task state into a state in task execution.
Mode two: in the case that the execution of the plurality of asynchronous folder replication sub-tasks is completed, the task state is changed to all task execution completion state.
Mode three: and under the condition that any asynchronous folder replication subtask fails to execute, changing the task state into a task execution failure state.
If any asynchronous folder replication subtask transmits an execution failure condition in execution, before the task exits, the task state of the folder replication task in the task database table is changed into a task execution failure state, and the task database table records a target asynchronous folder replication subtask corresponding to a breakpoint of the task according to an execution queue in the task information of the folder replication task, so that the target asynchronous folder replication subtask which fails to be executed can be restarted through the task execution failure state and the task breakpoint in the follow-up, and by the mode, the success rate of task execution is improved, and the problem of data consistency after the file replication failure is guaranteed.
S209, canceling the pointing relation after detecting that the task state of the folder copying task is the completion state of all task execution.
The method comprises the steps of calling a task database table according to a preset period, detecting the task state of a current folder replication task, determining that replication is completed after detecting that the task state of the folder replication task is the completion state of all task execution, and canceling the pointing relation of a target folder so that the subsequent operation on the target folder can be normally executed on the target folder. In the embodiment where the pointing relationship is a soft link, canceling the pointing relationship is specifically: the soft link is deleted.
The duration of the preset period may be set arbitrarily according to a specific implementation manner, for example, set to 20ms.
Specifically, S206-S209 are one implementation of S102, and specifically, S102 has other implementations, which are not limited herein. And, in the case that the number of subfile objects included in the source folder is large, the method may be executed in the manner of S206-S209, and in the case that the number of subfile objects included in the source folder is small, S206-S209 may be omitted, and all the subfile objects to be copied may be directly packaged into a single task for execution.
S210, deleting task identification, task information and association relation of the folder replication task in the task database table.
After the task execution is determined to be completed, in other words, after the task state of the folder replication task is detected to be all the task execution completion state, the task identification, the task information and the association relation of the folder replication task are deleted from the task database table, so that the redundant information of the task database table can be reduced, and the completed folder replication task can be prevented from being triggered by mistake.
S211, setting the folder state of the target folder to be a copy completion state.
After determining that the task execution is completed, in other words, after detecting that the task state of the folder replication task is all the task execution completion state, the folder state of the target folder is set to the replication completion state, so that when the task execution is completed (i.e., the folder state is the replication completion state), the operation for the target folder is directly performed on the target folder, and the change operation can be performed on the target folder and the source folder.
The execution order of S210 and S211 may be changed, and is not limited herein.
Based on the above, the present disclosure further provides an exception handling mechanism for task exceptions in executing a folder replication task. Specifically, based on the third mode S208, S208 further includes:
Step one: and detecting the task state according to a preset period.
The duration of the preset period may be set arbitrarily according to a specific implementation manner, for example, set to 15ms. The first step is to set a periodic abnormality detection period to detect task states and discover task abnormalities in time.
Step two: and carrying out corresponding task processing operation on the folder copying task according to the task state detection condition.
The matching relationship between multiple groups of detection cases and task processing operations can be preset, wherein the detection cases comprise one of the following: the task state is a task execution failure state, and the operation time of copying the subtask of any asynchronous folder exceeds a preset threshold; the task processing operations include one of: and determining a task break point, restarting the target asynchronous folder replication subtask, and restarting the asynchronous folder replication subtask with the operation time exceeding a preset threshold value.
Specifically, in some examples, step two includes the sub-steps of:
and step one, determining a task break point under the condition that the task state is detected to be the task execution failure state.
And step two, determining a target asynchronous folder replication subtask corresponding to the task break point, and restarting the target asynchronous folder replication subtask.
According to the third mode of S208, if any one of the asynchronous folder replication sub-tasks fails to be executed, before the task exits, the task state of the folder replication task in the task database table is changed to a task execution failure state, and the task database table records the target asynchronous folder replication sub-task corresponding to the task interrupt point in the task information of the folder replication task according to the execution queue, so that in the first and second sub-steps a, if the task state is detected to be the task execution failure state, the task interrupt point can be determined through the task database table, and the step folder replication sub-task with the execution failure can be determined to be the target asynchronous folder replication sub-task through the task endpoint, and then the target asynchronous folder replication sub-task with the execution failure is restarted.
Alternatively, step two comprises the sub-steps of:
and B, interrupting the asynchronous folder copying sub-task with the operation time exceeding the preset threshold value under the condition that the operation time of any asynchronous folder copying sub-task is detected to exceed the preset threshold value.
And step B, restarting the asynchronous folder copying subtask with the operation time exceeding a preset threshold value.
The preset threshold is a reference time for judging task jam, and may be set according to specific implementation requirements, for example, may be set to 1 minute.
In some cases, the asynchronous folder replication subtask may exit abnormally, and the task state is not changed to be the task execution failure state, in this case, the task state is kept to be the task execution state, so that the abnormality is not found, therefore, a preset threshold of an abnormal period can be set, after the operation time of the current task in the task data table is determined to exceed the preset threshold, the occurrence of the abnormality of the task can be determined, namely, the interrupt operation is performed on the current asynchronous folder replication subtask, the task state is changed to be the task execution failure state, and a restarting mechanism is triggered, and the asynchronous folder replication subtask with the operation time exceeding the preset threshold is restarted.
By the method, the task abnormality can be found in time and the abnormality interference can be carried out, so that the success rate of task copying and the consistency of data are ensured.
It should be noted that, the first step and the second step may be performed at any period of time (specifically, periodically performed according to a preset period) in the whole process after S207 and before S209, which is not limited herein.
Based on the foregoing, the present disclosure also provides a mechanism for protecting the file integrity of the source folder and the target folder during the execution of the folder replication task. Specifically, referring to fig. 3, fig. 3 is a flowchart illustrating a step of protecting a copy file in a method for copying a folder provided in the present disclosure. Based on the above embodiment in which the folder status is set in S205, the method for copying a folder provided in the present disclosure further includes:
s201', determining a folder state of the target folder in response to a file change operation for any one of the source folder, the target folder and any one of the target folder.
S202', determining the execution mode of the file change operation according to the state of the folder.
In order to protect the integrity of the source folder and the files therein, the target folder and the files therein, whether the copying task is completed or not can be known through the folder state of the target folder, and in the case that the copying task is not completed, the operation (namely, the file changing operation) which can damage the integrity of the source folder and the files therein is not performed, and only the checking operation is allowed to be performed, so that the integrity of the files is protected, the files are prevented from being deleted by mistake before the copying task is not completed, and the reliability of the copying method of the folders provided by the embodiment of the disclosure is improved.
Specifically, S202' includes the following cases:
(1) And executing file changing operation under the condition that the folder state is determined to be the copy completion state.
If the folder state is detected to be the copy completion state, the completion of the execution of the copy task can be determined, and in this case, the folder is not locked any more, so that the file change operation can be normally executed.
(2) In the case where it is determined that the folder state is the copy incomplete state, the execution mode of the file change operation is determined according to any one of the following.
Mode one: and prohibiting the execution of the file change operation.
Mode two: generating an asynchronous file change task according to the file change operation; and executing the asynchronous file change task under the condition that the folder state is detected to be the copy completion state.
If the folder state is detected to be in a non-copy completion state, namely the copy task is not executed and completed, at the moment, the integrity of the file needs to be protected, the execution operation can be directly forbidden, or an asynchronous file change task is generated for the change operation, after the asynchronous file change task is generated, the related information of the asynchronous file change task can be stored in the task database table for queuing, and when the folder state is detected to be in the copy completion state, the asynchronous file change task is executed according to the queuing sequence, and the related information of the asynchronous file change task is deleted from the task database table after the execution is completed.
The file change operation at least comprises the following steps: any one of the operations of a delete operation, a transfer operation, and the like.
It should be noted that S201 'and S202' may be performed at any period during the document copying process, and are not limited herein.
In disclosing a third embodiment, based on the same principle as fig. 1, fig. 4 shows a copying apparatus 40 of a folder provided by the third embodiment of the present disclosure, the apparatus comprising:
the task creation module 401 is configured to create a folder replication task in response to a folder replication request.
And a pointing relation creation module 402, configured to create a target folder corresponding to the source folder at a target location that matches the folder replication request, and create a pointing relation on the target folder, where the pointing relation points to the source folder from the target folder, and the pointing relation is used to point a user's operation on the target folder to the source folder.
The task execution module 403 is configured to execute a folder replication task, replicate a file in a source folder into a target folder, and cancel the pointing relationship after replication is completed.
The pointing relationship is represented as a soft link; the pointing relation creation module is specifically configured to:
a soft link is created on the target folder from the target folder to the source folder.
In some examples, the task creation module includes:
the generating sub-module is used for generating a folder copying task according to task information contained in the folder copying request, wherein the task information comprises: a source folder, a target folder;
the identification allocation sub-module is used for allocating task identifications to the folder copying tasks, adding operation time and task states into the task information, and establishing association relations between the task identifications and the task information;
and the table storage sub-module is used for recording the task identification, the task information and the association relation of the task identification and the task information to a preset task database table.
In some examples, the folder replication task is an asynchronous task; the apparatus further comprises:
the grouping module is used for dividing a plurality of sub-file objects contained in the source folder into a plurality of object groups;
the subtask generation module is used for generating a plurality of asynchronous folder replication subtasks aiming at a plurality of object groups;
the subtask execution module is used for sequentially executing a plurality of asynchronous folder replication subtasks and updating the task state of the folder replication tasks in the task database table according to the execution progress;
and the pointing relation management module is used for canceling the pointing relation after detecting that the task state of the folder copying task is the execution completion state of all the tasks.
In some examples, the apparatus further comprises:
and the task information deleting module is used for deleting the task identification, the task information and the association relation of the folder copying task in the task database table.
In some examples, the subtask execution module has a logic to:
sequentially executing a plurality of asynchronous folder replication subtasks, and changing the task state into a task executing state;
or under the condition that the execution of the plurality of asynchronous folder replication subtasks is completed, changing the task state into all task execution completion states;
or, in the case that any asynchronous folder replication subtask fails to execute, changing the task state into a task execution failure state.
In some examples, the apparatus further comprises:
the detection module is used for detecting the task state according to a preset period;
and the processing module is used for carrying out corresponding task processing operation on the folder copying task according to the task state detection condition.
In some examples, the processing module is specifically to:
determining a task break point under the condition that the task state is detected to be a task execution failure state;
determining a target asynchronous folder replication subtask corresponding to the task break point, and restarting the target asynchronous folder replication subtask;
Or alternatively, the first and second heat exchangers may be,
under the condition that the operation time of any asynchronous folder copying sub-task exceeds a preset threshold value, interrupting the asynchronous folder copying sub-task with the operation time exceeding the preset threshold value;
restarting the asynchronous folder replication subtask with the operation time exceeding a preset threshold.
In some examples, the apparatus further comprises:
a first state module for setting a folder state of the target folder to a copy incomplete state;
in some examples, the apparatus further comprises:
and the second state module is used for setting the folder state of the target folder to be a copy completion state.
In some examples, the apparatus further comprises:
a folder state determining module, configured to determine a folder state of a target folder in response to a file change operation for any one of a source folder, a target folder, and a target folder;
and the execution mode determining module is used for determining the execution mode of the file changing operation according to the folder state.
In some examples, the execution manner determination module is to:
executing file changing operation under the condition that the folder state is determined to be the copy completion state;
Or, in the case of determining that the folder state is the copy incomplete state, determining the execution manner of the file change operation according to any one of the following:
forbidding execution of file change operation;
or alternatively, the first and second heat exchangers may be,
generating an asynchronous file change task according to the file change operation;
executing an asynchronous file change task under the condition that the folder state is detected to be a copy completion state;
the file changing operation comprises the following steps: either a delete operation or a transfer operation.
In some examples, the apparatus further comprises:
a state determining module for determining a folder state of the target folder in response to a file viewing operation for any one of the target folder and any one of the files in the target folder;
the target file determining module is used for directing the file viewing operation to the source folder according to the directing relation and determining a target file corresponding to the file viewing operation in the source folder under the condition that the folder state is determined to be the copying incomplete state;
and the operation execution module is used for executing file viewing operation on the target file.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the related user personal information all conform to the regulations of related laws and regulations, and the public sequence is not violated.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
Fig. 5 illustrates a schematic block diagram of an example electronic device 500 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 5, the apparatus 500 includes a computing unit 501 that can perform various suitable actions and processes according to a computer program stored in a Read Only Memory (ROM) 502 or a computer program loaded from a storage unit 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, ROM502, and RAM503 are connected to each other by a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Various components in the device 500 are connected to the I/O interface 505, including: an input unit 506 such as a keyboard, a mouse, etc.; an output unit 507 such as various types of displays, speakers, and the like; a storage unit 508 such as a magnetic disk, an optical disk, or the like; and a communication unit 509 such as a network card, modem, wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The computing unit 501 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 501 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the respective methods and processes described above, such as a copy method of folders. For example, in some embodiments, the method of copying folders may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 500 via the ROM502 and/or the communication unit 509. When the computer program is loaded into RAM503 and executed by computing unit 501, one or more steps of the above-described folder replication method may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the method of copying folders in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (20)

1. A method of copying folders, the method comprising:
creating a folder replication task in response to a folder replication request from a source folder to a target location;
creating a target folder corresponding to the source folder at a target position matched with the folder replication request, and creating a pointing relation pointed to the source folder by the target folder on the target folder, wherein the pointing relation is used for pointing the operation of a user on the target folder to the source folder;
And executing the folder copying task, copying the files in the source folder into the target folder, and canceling the pointing relationship after copying is completed.
2. The method of claim 1, wherein the pointing relationship is represented as a soft link; the creating a pointing relationship on the target folder, the pointing relationship being pointed to by the target folder to the source folder, includes:
a soft link is created on the target folder from the target folder to the source folder.
3. The method of claim 1 or 2, wherein the creating a folder replication task in response to a folder replication request comprises:
generating a folder copying task according to task information contained in the folder copying request, wherein the task information comprises: a source folder, a target folder;
task identification is distributed to the folder copying task, operation time and task state are added in task information, and an association relation between the task identification and the task information is established;
and recording the task identification, the task information and the association relation of the task identification and the task information to a preset task database table.
4. A method according to claim 3, wherein the folder replication task is an asynchronous task; the executing the folder copying task, copying the files in the source folder into the target folder, and canceling the pointing relationship after copying is completed, including:
dividing a plurality of sub-file objects contained in the source folder into a plurality of object groups;
generating a plurality of asynchronous folder replicator subtasks for the plurality of object groups respectively;
sequentially executing the plurality of asynchronous folder copying sub-tasks, and updating the task state of the folder copying task in the task database table according to the execution progress;
and canceling the pointing relation after detecting that the task state of the folder copying task is the completion state of all task execution.
5. The method of claim 4, wherein after the pointing relationship is canceled after detecting that the task state of the folder replication task is an all task execution completion state, the method further comprises:
and deleting the task identification, the task information and the association relation of the folder replication task in the task database table.
6. The method of claim 4 or 5, wherein the sequentially executing the plurality of asynchronous folder replication sub-tasks and updating the task state of the folder replication tasks in the task database table according to execution progress comprises any one of:
sequentially executing the plurality of asynchronous folder replication subtasks, and changing the task state into a task executing state;
changing the task state into all task execution completion states under the condition that the execution of the plurality of asynchronous folder replication subtasks is completed;
and under the condition that any asynchronous folder replication subtask fails to execute, changing the task state into a task execution failure state.
7. The method according to any one of claims 4-6, wherein said sequentially executing said plurality of asynchronous folder replication sub-tasks and updating said task state of said folder replication tasks in said task database table according to execution progress, further comprises:
detecting the task state according to a preset period;
and carrying out corresponding task processing operation on the folder copying task according to the task state detection condition.
8. The method of claim 7, wherein the performing a corresponding task processing operation on the folder replication task according to the task state detection condition includes:
Determining the task break point under the condition that the task state is detected to be a task execution failure state;
determining a target asynchronous folder replication subtask corresponding to the task break point, and restarting the target asynchronous folder replication subtask;
or alternatively, the first and second heat exchangers may be,
under the condition that the operation time of any asynchronous folder copying sub-task exceeds a preset threshold value, interrupting the asynchronous folder copying sub-task of which the operation time exceeds the preset threshold value;
restarting the asynchronous folder replication subtask of which the operation time exceeds a preset threshold value.
9. The method of any of claims 1-8, wherein after creating a target folder corresponding to the source folder at a target location that matches the folder replication request and creating a pointing relationship on the target folder that points to the source folder by the target folder, and after performing the folder replication task, replicating files in the source folder into the target folder, and after replication is completed, before canceling the pointing relationship, the method further comprises:
setting a folder state of the target folder to a copy incomplete state;
The method further comprises the steps of executing the folder copying task, copying files in the source folder into the target folder, and canceling the pointing relationship after copying is completed, wherein the method further comprises the steps of:
and setting the folder state of the target folder to be a copy completion state.
10. The method of claim 9, wherein the method further comprises:
determining a folder state of the target folder in response to a file change operation for any one of the source folder, the target folder, and any one of the target folder;
and determining the execution mode of the file change operation according to the folder state.
11. The method of claim 10, wherein the determining the manner in which the file change operation is performed based on the folder state comprises:
executing the file changing operation under the condition that the folder state is determined to be the copy completion state;
in the case that the folder state is determined to be the copy incomplete state, determining an execution mode of the file change operation according to any one of the following:
prohibiting execution of the file change operation;
Or alternatively, the first and second heat exchangers may be,
generating an asynchronous file change task according to the file change operation;
executing the asynchronous file change task under the condition that the folder state is detected to be a copy completion state;
wherein the file change operation includes: either a delete operation or a transfer operation.
12. The method of any of claims 9-11, wherein the creating a target folder corresponding to the source folder at a target location that matches the folder replication request, and creating a pointing relationship on the target folder that points to the source folder by the target folder, the pointing relationship being used to point a user operation on the target folder to the source folder, further comprises:
determining a folder state of the target folder in response to a file view operation for any one of the target folder and any one of the files in the target folder;
under the condition that the folder state is determined to be in a copying incomplete state, pointing the file viewing operation to the source folder according to the pointing relation, and determining a target file corresponding to the file viewing operation in the source folder;
And executing the file viewing operation aiming at the target file.
13. A copying apparatus for a folder, the apparatus comprising:
the task creation module is used for responding to the folder copying request and creating a folder copying task;
the pointing relation creation module is used for creating a target folder corresponding to the source folder at a target position matched with the folder replication request, creating a pointing relation pointed to the source folder by the target folder on the target folder, and pointing the operation of a user on the target folder to the source folder;
and the task execution module is used for executing the folder copying task, copying the files in the source folder into the target folder, and canceling the pointing relationship after the copying is completed.
14. The apparatus of claim 13, wherein the pointing relationship is represented as a soft link; the pointing relation creation module is specifically configured to:
a soft link is created on the target folder from the target folder to the source folder.
15. The apparatus of claim 13 or 14, wherein the task creation module comprises:
The generating sub-module is used for generating a folder copying task according to task information contained in the folder copying request, wherein the task information comprises: a source folder, a target folder;
the identification allocation sub-module is used for allocating task identifications to the folder copying tasks, adding operation time and task states into task information, and establishing association relations between the task identifications and the task information;
and the table storage sub-module is used for recording the task identifier, the task information and the association relation of the task identifier and the task information to a preset task database table.
16. The apparatus of claim 15, wherein the folder replication task is an asynchronous task; the apparatus further comprises:
the grouping module is used for dividing a plurality of sub-file objects contained in the source folder into a plurality of object groups;
the subtask generation module is used for generating a plurality of asynchronous folder replication subtasks aiming at the plurality of object objects respectively;
the subtask execution module is used for sequentially executing the plurality of asynchronous folder replication subtasks and updating the task state of the folder replication tasks in the task database table according to the execution progress;
And the pointing relation management module is used for canceling the pointing relation after detecting that the task state of the folder copying task is the completion state of all task execution.
17. The apparatus of claim 16, wherein the apparatus further comprises:
and the task information deleting module is used for deleting the task identifier, the task information and the association relation of the folder copying task in the task database table.
18. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-12.
19. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-12.
20. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-12.
CN202310622976.1A 2023-05-29 2023-05-29 File copying method and device, electronic equipment and storage medium Pending CN117251417A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310622976.1A CN117251417A (en) 2023-05-29 2023-05-29 File copying method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310622976.1A CN117251417A (en) 2023-05-29 2023-05-29 File copying method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117251417A true CN117251417A (en) 2023-12-19

Family

ID=89130130

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310622976.1A Pending CN117251417A (en) 2023-05-29 2023-05-29 File copying method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117251417A (en)

Similar Documents

Publication Publication Date Title
CN112650576B (en) Resource scheduling method, device, equipment, storage medium and computer program product
US9342251B2 (en) Data integrity protection in storage volumes
CN114969840A (en) Data leakage prevention method and device
CN111290836A (en) Virtual machine snapshot creating method and device, storage medium and computer equipment
CN113641544A (en) Method, apparatus, device, medium and product for detecting application status
CN108733536B (en) Monitoring management system and method
CN112965799A (en) Task state prompting method and device, electronic equipment and medium
CN117251417A (en) File copying method and device, electronic equipment and storage medium
CN114513468B (en) Method, device, equipment, storage medium and product for protecting flow in Sentinel
CN112925623B (en) Task processing method, device, electronic equipment and medium
CN115510036A (en) Data migration method, device, equipment and storage medium
CN114329164A (en) Method, apparatus, device, medium and product for processing data
CN114546705B (en) Operation response method, operation response device, electronic apparatus, and storage medium
CN116821893B (en) Code execution method, device, electronic equipment and storage medium
CN113673890B (en) Cloud mobile phone resource order processing method, related device and computer program product
CN116451272A (en) Git-based code library control method and device and electronic equipment
CN117632492A (en) Resource management method and device, storage medium and electronic equipment
CN116755936A (en) Application program management method, device, equipment and storage medium
CN114491674A (en) Log processing method, device and equipment based on block chain
CN115529346A (en) Service changing method, device, equipment and storage medium
CN116896587A (en) Processing method and device for repeated network request, computer equipment and storage medium
CN116204291A (en) Task processing method, device, computer equipment and storage medium
CN112836907A (en) Incompatible job information processing method, device and system
CN114615229A (en) Information processing method and device
CN116821144A (en) Upgrading method, device, equipment and storage medium

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