File synchronization method and device and medium
By managing a file synchronization data table between the primary and backup machines, the resource consumption and learning costs caused by relying on third-party components in existing technologies are resolved, achieving efficient file synchronization.
Patent Information
- Application Number
- CN202511546049.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-28
- Publication Date
- 2026-03-03
AI Technical Summary
Existing file synchronization methods rely on third-party components, consume computational and memory resources, and have a learning curve.
This paper provides a file synchronization method that uses a file synchronization data table corresponding to preset variables based on preset conditions to achieve file synchronization between the primary and backup machines. This method includes the management of file upload and deletion times, avoiding the use of third-party components.
It enables file synchronization between primary and backup machines without the need for third-party components, reducing the consumption of computing and memory resources and lowering the learning cost.
Smart Images

Figure CN121597650A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a file synchronization method, device, and medium. Background Technology
[0002] In internet services, to meet the requirements of high availability, a dual-machine backup deployment method is often adopted. Dual-machine backup requires that after the primary server (master) fails, the backup server (standby machine) will automatically take over after detecting the failure of the primary server, and vice versa, so as to achieve mutual master and backup. Therefore, the files of the primary and backup servers must be copied in both directions, that is, file synchronization.
[0003] Existing file synchronization solutions generally use third-party open-source components such as Rsync or Syncthing. These solutions require the installation and deployment of third-party components, which consumes the device's computing and memory resources. In addition, the components need to be configured to work properly, which involves a certain learning curve. Summary of the Invention
[0004] This application provides a file synchronization method, device, and medium, which can solve the problems of existing file synchronization methods relying on third-party components, consuming computing and memory resources, and incurring learning costs.
[0005] To achieve this objective, the embodiments of this application provide the following solutions.
[0006] According to one aspect of the embodiments of this application, a file synchronization method is provided, applied to a standby machine connected to a host, the method comprising: Based on preset conditions, query the file synchronization data table corresponding to preset variables. The preset variables are used to store the last change time and / or last deletion time of the file. If it is determined that there are records in the file synchronization data table that are later than the preset variable, then file synchronization is performed based on the records, which include the upload time, modification time, or deletion time of the file.
[0007] In one possible implementation, the method includes: Determine that the initialization conditions are met, and initialize the preset variables according to the configuration file. The initialization conditions include power-on. The configuration file stores the values of the preset variables. The file synchronization based on the recorded data includes: Once the file synchronization is complete, update the configuration file based on the synchronization results.
[0008] In one possible implementation, the preset conditions include the current data query time, the preset variables include a first variable, the file synchronization data table includes a file upload table, the first variable stores the last change time corresponding to the file, and the file upload table stores information about file upload or modification, including file name, file identifier, file save path, and last modification time. The step of querying the file synchronization data table corresponding to preset variables based on preset conditions includes: If the current time is determined to be the data query time corresponding to the first variable, then information whose last modification time is greater than the last change time is queried in the file upload table.
[0009] In one possible implementation, the acquisition of the recorded data includes: If it is determined that there is information whose last modification time is greater than the last change time, then the information is stored in sequence as a first array object.
[0010] In one possible implementation, the file synchronization based on the recorded data includes: Iterate through the information in the first array object; If a corresponding local file is determined to exist based on the file storage path of the information, and the file identifier of the local file does not match the file identifier in the information, then the file corresponding to the information is downloaded from the host based on the information.
[0011] In one possible implementation, the preset variable includes a second variable, the file synchronization data table includes a file deletion table, the second variable stores the last deletion time corresponding to the file, and the file deletion table stores deletion information of deleted files in the host, the deletion information including file name, file save path, creation time, and physical address; The step of querying the file synchronization data table corresponding to preset variables based on preset conditions includes: If the current time is determined to be the data query time corresponding to the second variable, then query the file deletion table for deletion information whose creation time is greater than the last deletion time; The acquisition of the recorded data includes: Obtain deletion information from the file deletion table whose creation time is greater than the last deletion time, and store the deletion information as a second array object.
[0012] In one possible implementation, the file synchronization based on the recorded data includes: Iterate through the deletion information in the second data object; If the physical address in the deletion information indicates that the record for the deletion information was created on the host, then the corresponding file is deleted based on the file save path in the deletion information, and the deletion information corresponding to the file is also deleted.
[0013] In one possible implementation, the method includes: Obtain the file synchronization information transmitted by the host, and update the stored file synchronization data table based on the file synchronization information, wherein the file synchronization information is sent by the host when performing file upload and / or file deletion operations; or If a file upload and / or file deletion operation is detected, corresponding file synchronization information is generated and sent to the host to update the file synchronization data table.
[0014] According to one aspect of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described above.
[0015] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed, implements the steps of the method described above.
[0016] The beneficial effects of the technical solutions provided in this application are: The file synchronization method provided in this application includes: querying a file synchronization data table corresponding to preset variables based on preset conditions, where the preset variables are used to store the last change time and / or last deletion time of the file; if it is determined that there are records in the file synchronization data table that are later than the preset variables, then file synchronization is performed based on the records, where the records include the upload time or deletion time of the file. This application embodiment can achieve file synchronization between primary and backup machines through preset variables and a file synchronization data table, without the need for third-party components, effectively reducing the consumption of computing and memory resources, and has a low learning curve. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0018] Figure 1 A flowchart illustrating the file synchronization method provided in this application embodiment; Figure 2 A schematic diagram illustrating file synchronization for adding or modifying files as provided in the embodiments of this application; Figure 3A schematic diagram illustrating file synchronization corresponding to file deletion provided in this application embodiment; Figure 4 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0019] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0020] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” indicates implementation as “A,” or implementation as “A,” or implementation as “A and B.”
[0021] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0022] The technical solutions of the embodiments of the present invention and the technical effects produced by the technical solutions of the present invention will be described below through several exemplary embodiments. It should be noted that the following embodiments can be referred to, learned from, or combined with each other, and the same terms, similar features, and similar implementation steps in different embodiments will not be described again.
[0023] The file synchronization method, device, and medium provided in this application are intended to solve at least one technical problem existing in the prior art.
[0024] This application provides a file synchronization method that can be used on mobile phones, computers, servers, and other objects that can be used for file synchronization.
[0025] Optionally, such as Figures 1-3As shown, this file synchronization method is used on a standby machine connected to the primary machine, and can also be used on a primary machine connected to a standby machine. When either the standby machine or the primary machine needs file synchronization (such as file changes like addition, modification, or deletion), the data in the file synchronization data table of the other machine, as well as the values of preset variables, are synchronized. This file synchronization method includes: S101: Query the file synchronization data table corresponding to the preset variables based on preset conditions.
[0026] Optionally, a preset variable is used to store the last modified time and / or last deleted time of the file.
[0027] Optionally, to improve the accuracy of file synchronization and ensure that the device can perform file synchronization normally after each startup, whether due to power failure, restart, or execution of the application using the method of this application, the method of this application further includes: determining that the initialization conditions are currently met, and initializing preset variables according to the configuration file. The initialization conditions include power-on, and the configuration file stores the values of the preset variables. The initialization conditions may also include the startup of the business system installed on the host or backup machine, the startup of the application on the host or backup machine, and other conditions that indicate the initial start of file synchronization.
[0028] Optionally, the configuration file stores the latest values of preset variables. Both the primary and backup machines can have configuration files, and both can update the preset variables and the configuration file accordingly based on changes to their own files (such as file uploads, modifications, or deletions). Furthermore, when the primary and backup machines are powered off or lose power, the configuration file is automatically saved for use the next time (such as when the primary and backup machines are powered on again and the preset variables are initialized).
[0029] Optionally, the data in the file synchronization data table is generated based on file operations (such as upload, modification, and deletion) performed by the host and backup machine. To facilitate file synchronization, the method of this application includes: acquiring file synchronization information transmitted by the host; updating the stored file synchronization data table based on the file synchronization information, wherein the file synchronization information is sent by the host when performing a file upload and / or file deletion operation; or, if a file upload and / or file deletion operation is detected, generating corresponding file synchronization information and sending the file synchronization information to the host to update the file synchronization data table.
[0030] Optionally, preset conditions include the current data query time, allowing for timed control of file synchronization operations between the primary and backup machines. The data query times for the primary and backup machines can be the same or different. Alternatively, preset conditions can include receiving a file synchronization command or receiving modified file synchronization data table information from the primary machine. The specific information of the preset conditions can be determined according to actual needs.
[0031] Optionally, the preset variables include a first variable, and the file synchronization data table includes a file upload table. The first variable stores the last change time of the file, and the file upload table stores information about file uploads or modifications in the host and backup machines. This information includes the file name, file identifier, file save path, and last modification time.
[0032] In one embodiment, the file upload table is an upload_file data table, which is used to store information about files uploaded to the business systems of the host and backup machines, as well as file modification information. The fields in the data table include the file name (file_name), file MD5 value (md5_val), file save path (file_path), and last modified time (last_modified) for each file.
[0033] Optionally, the file synchronization data table corresponding to the preset variable can be queried based on preset conditions, including: if the current time is determined to be the data query time corresponding to the first variable, then information in the file upload table whose last modification time is greater than the last change time can be queried.
[0034] In one embodiment, the standby machine starts a thread that periodically queries the upload_file (file upload table) for records where last_modified is greater than or equal to the last_update_time value (the value of the first variable).
[0035] Optionally, the preset variables include a second variable, and the file synchronization data table includes a file deletion table. The second variable stores the last deletion time of the files in the host and the standby machine, and the file deletion table stores the deletion information of the deleted files in the host, including the file name, file save path, creation time, and physical address.
[0036] In one embodiment, upon initial execution of the method of this application, a new `deleted_file` data table (file deletion table) is created. This table stores deletion information for files deleted by the business systems of the primary and backup machines. The fields (i.e., records) in the table include the file name (`file_name`), file path (`file_path`), creation time (`create_time`), and physical address (`mac_address`) of the deleted file. The creation time is the time the file was created, and the physical address is the address of the device (e.g., the primary machine) where the user calls the deletion interface to perform the deletion operation. When a user calls the file deletion interface on the primary machine to perform a deletion operation, the corresponding local file on the primary machine is deleted first, and a record for the deleted file is simultaneously created in the `deleted_file` data table. The value of the `mac_address` field is the MAC address of the primary machine. Furthermore, after updating the file deletion table on the primary machine, based on the database synchronization mechanism, the newly added records in the file deletion table are synchronized to the file deletion table on the backup machine for data querying.
[0037] Optionally, the file synchronization data table corresponding to the preset variable is queried based on preset conditions, including: if the current time is determined to be the data query time corresponding to the second variable, then the deletion information with the creation time greater than the last deletion time is queried in the file deletion table.
[0038] In one embodiment, the standby machine starts a thread that periodically queries the file deletion table (deleted_file) for records where the create_time is greater than or equal to the last_deleted_time value (the value of the second variable).
[0039] S102: If it is determined that there are records in the file synchronization data table that are later than the preset variable, then file synchronization is performed based on the records.
[0040] Optionally, the recorded data includes the upload time, modification time, or deletion time of the file. When the recorded data includes the upload or modification time of the file, the acquisition of the recorded data includes: if it is determined that there is information where the last modification time is greater than the last change time, then the information is stored sequentially as a first array object.
[0041] Optionally, the information in the first array object can be sorted in ascending order based on the last modification time.
[0042] Optionally, when the recorded data includes the file deletion time, the data acquisition includes: acquiring deletion information from the file deletion table whose creation time is greater than the last deletion time, and storing the deletion information as a second array object.
[0043] Optionally, the deletion information in the second data object can be sorted in ascending order according to the corresponding creation time to avoid the value of the preset variable not corresponding to the latest upload time, modification time, or deletion time after file synchronization. Specifically, the second data object and the first data queue can be array objects query_list.
[0044] In one embodiment, after querying the file upload table, records with a last_modified value greater than or equal to the last_update_time value are retrieved, and the records are sorted in ascending order by last_modified (i.e., arranged in ascending order based on the last_modified field). The query result is then stored as an array object `query_list`. Similarly, after querying the file deletion table, records in `deleted_file` with a create_time value greater than or equal to the last_deleted_time value are retrieved, and the records are sorted in ascending order by create_time. The query result is then stored as an array object `query_list`.
[0045] Optionally, when the recorded data is the query result of the file upload table, file synchronization is performed based on the recorded data, including: traversing the information in the first array object; if it is determined that a corresponding local file exists based on the file save path of the information and the file identifier of the local file is inconsistent with the file identifier in the information, then the file corresponding to the information is downloaded from the host based on the information.
[0046] Optionally, if it is determined from the file save path that a corresponding local file does not exist, a download request can be generated based on the information corresponding to that file save path. This download request is then sent to the host, the file transferred by the host is retrieved, and stored. The download request can be an HTTP download request.
[0047] Optionally, if it is determined that a corresponding local file exists and the identifier of the local file is consistent with the identifier in the record data, then it is determined that file synchronization is not required, and only the values of preset variables are updated based on the record data.
[0048] Optionally, the identifier can be an MD5 value. When uploading a file to the host, an MD5 hash is calculated on the uploaded file and stored in the `md5_val` field. The `md5_val` field is used for data integrity verification based on the file's MD5 value after the file is downloaded synchronously on the standby machine. Furthermore, after a file is modified, the object containing the file (host or standby machine) will also recalculate the MD5 hash of the modified file and store the new MD5 value in the file upload table.
[0049] In one embodiment, the query results of the file upload table are stored as an array object `query_list`. The `file_name`, `file_path`, `md5_val`, and `last_modified` of each element in `query_list` are retrieved iteratively. First, it checks if a file with the same save path exists locally based on `file_path`. If it exists, the MD5 value of the local file is calculated and compared with the element's `md5_val`. If they match, the file has been correctly synchronized; otherwise, an HTTP download request is constructed and sent to the host to download the file named `file_name` and perform MD5 verification. If the file download or MD5 verification fails, the relevant information is logged. Regardless of success or failure, the `last_update_time` value needs to be updated (after updating, the corresponding element in the `query_list` array object does not need to be deleted; `query_list` only temporarily stores the database query results and will be automatically discarded and recycled after use) to the current `last_modified` value, and then the process continues to the next record.
[0050] Optionally, when the recorded data includes file deletion information, file synchronization is performed based on the recorded data, including: traversing the deletion information in the second data object; if it is determined from the physical address in the deletion information that the record of the deletion information was created on the host, then the corresponding file is deleted based on the file save path in the deletion information, and the deletion information corresponding to the file is deleted.
[0051] In one embodiment, the query results are stored as an array object `query_list`. During file synchronization, the `file_name`, `file_path`, `mac_address`, and `create_time` of each element in `query_list` are retrieved in a loop. The `mac_address` is compared to the local `mac_address` to determine if the element is a deletion record created by another business system. If so, the file is deleted directly based on the `file_path`, and the record is deleted simultaneously; otherwise, no action is taken. If file deletion fails, the failure information is logged. Regardless of success or failure, the `last_delete_time` value is updated to the `create_time` value of the current record, and processing continues for the next record. In this process, the user calls the file deletion interface on the primary machine to perform a deletion operation. First, the local file is deleted, and simultaneously, a record for the deleted file is created in the `deleted_file` table. The value of the `mac_address` field is the MAC address of the primary machine. This record is synchronized to the standby machine via the database synchronization mechanism. The standby machine retrieves this record, parses the `mac_address` field, and compares it with its own MAC address. If they are not equal, it indicates that the record was generated by the primary machine's deletion operation, and the standby machine needs to perform a file synchronization deletion operation locally. Otherwise, if they are equal, it indicates that the record was generated by the standby machine itself, and no action is needed because the deletion operation has already been performed. This distinguishes between records from the primary machine and records from non-primary machines, avoiding duplicate processing.
[0052] Optionally, the primary and backup machines can synchronize file data tables via a dual-master replication mechanism using MySQL (or other databases with data synchronization capabilities such as PostgreSQL or Oracle). Regardless of changes to the `upload_file` and `deleted_file` tables on either the primary or backup machine, these changes will be synchronized to the other machine. Based on the above steps and the synchronized file data tables, data synchronization for file addition, modification, and deletion operations is achieved, ultimately realizing bidirectional file synchronization in the dual-machine backup system.
[0053] In one embodiment, such as Figure 2 , Figure 3As shown, both the primary and standby machines are equipped with a timer module and a file management module. The timer module includes change processing and deletion processing threads, while the file management module provides file upload, file modification, file deletion, and file download interfaces. Data synchronization between the primary and standby machines is achieved via MySQL. Users upload files through the file upload interface and modify files through the file modification interface. The uploaded and modified data are recorded in the MySQL file upload table, updating the table and recording upload and modification information. The MySQL data synchronization mechanism synchronizes the data from the file upload table to the standby machine's MySQL database. The standby machine uses the change processing thread of the timer module to periodically process the first variable. If the local file does not exist or exists but the MD5 hash is inconsistent, the standby machine uses the primary machine's file download interface to synchronize the file.
[0054] When a user deletes a file through the file deletion interface on the primary machine, the file deletion table is updated, and a corresponding file deletion record is added to the table. The data in the file deletion table is then synchronized to the standby machine's MySQL database using MySQL's data synchronization mechanism. After data synchronization, the standby machine uses a deletion processing thread to perform the file deletion operation.
[0055] The file synchronization method of this application embodiment has the following advantages: 1. Simple and flexible: It can be implemented based on the HTTP protocol, with a simple learning cost and no need to add complex development work or introduce additional third-party components.
[0056] 2. Low loss: The entire process does not involve complex calculations and has almost no impact on the normal operation of the equipment and resources.
[0057] 3. Simple to implement: Directly reuses the dual-master database replication capability, avoiding the problem of circular synchronization.
[0058] Based on the same inventive concept, embodiments of this application provide an electronic device, such as... Figure 4 As shown, Figure 4 The illustrated electronic device 2000 includes a processor 2001 and a memory 2003. The processor 2001 and the memory 2003 are communicatively connected, for example, via a bus 2002.
[0059] Processor 2001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 2001 may also be a combination that implements computing functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0060] Bus 2002 may include a pathway for transmitting information between the aforementioned components. Bus 2002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 2002 can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the figure, but this does not indicate that there is only one bus or one type of bus.
[0061] The memory 2003 may be ROM (Read-Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read-Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto.
[0062] Optionally, the electronic device 2000 may also include a communication unit 2004. The communication unit 2004 can be used for receiving and transmitting signals. The communication unit 2004 allows the electronic device 2000 to communicate wirelessly or wiredly with other devices to exchange data. It should be noted that in practical applications, the communication unit 2004 is not limited to one.
[0063] Optionally, the electronic device 2000 may further include an input unit 2005. The input unit 2005 can be used to receive input numbers, characters, images, and / or sound information, or to generate key signal inputs related to user settings and function control of the electronic device 2000. The input unit 2005 may include, but is not limited to, one or more of the following: a touchscreen, a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a trackball, a mouse, a joystick, a camera, a microphone, etc.
[0064] Optionally, the electronic device 2000 may also include an output unit 2006. The output unit 2006 can be used to output or display information processed by the processor 2001. The output unit 2006 may include, but is not limited to, one or more of a display device, a speaker, a vibration device, etc.
[0065] Although the electronic device 2000 with various devices is shown in the figure, it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0066] Optionally, the memory 2003 is used to store a computer program for executing the scheme of this application, and its execution is controlled by the processor 2001. The processor 2001 is used to execute the computer program stored in the memory 2003 to implement the steps of any method provided in the embodiments of this application.
[0067] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by an electronic device / processor, implements the steps of any method provided in this application or the steps of various optional implementations of the method provided in this application.
[0068] The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the illustrations or text descriptions.
[0069] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0070] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. A file synchronization method, characterized in that, Applied to a standby machine connected to a master unit, the method includes: Based on preset conditions, query the file synchronization data table corresponding to preset variables. The preset variables are used to store the last change time and / or last deletion time of the file. If it is determined that there are records in the file synchronization data table that are later than the preset variable, then file synchronization is performed based on the records, which include the upload time, modification time, or deletion time of the file.
2. The file synchronization method according to claim 1, characterized in that, The method includes: Determine that the initialization conditions are met, and initialize the preset variables according to the configuration file. The initialization conditions include power-on. The configuration file stores the values of the preset variables. The file synchronization based on the recorded data includes: Once the file synchronization is complete, update the configuration file based on the synchronization results.
3. The file synchronization method according to claim 1, characterized in that, The preset conditions include the current data query time, the preset variables include a first variable, the file synchronization data table includes a file upload table, the first variable stores the last change time corresponding to the file, and the file upload table stores information about file upload or modification, including file name, file identifier, file save path and last modification time. The step of querying the file synchronization data table corresponding to preset variables based on preset conditions includes: If the current time is determined to be the data query time corresponding to the first variable, then information whose last modification time is greater than the last change time is queried in the file upload table.
4. The file synchronization method according to claim 3, characterized in that, The acquisition of the recorded data includes: If it is determined that there is information whose last modification time is greater than the last change time, then the information is stored in sequence as a first array object.
5. The file synchronization method according to claim 4, characterized in that, The file synchronization based on the recorded data includes: Iterate through the information in the first array object; If a corresponding local file is determined to exist based on the file storage path of the information, and the file identifier of the local file does not match the file identifier in the information, then the file corresponding to the information is downloaded from the host based on the information.
6. The file synchronization method according to claim 3, characterized in that, The preset variable includes a second variable, the file synchronization data table includes a file deletion table, the second variable stores the last deletion time of the file, and the file deletion table stores the deletion information of deleted files in the host, the deletion information includes file name, file save path, creation time, and physical address; The step of querying the file synchronization data table corresponding to preset variables based on preset conditions includes: If the current time is determined to be the data query time corresponding to the second variable, then query the file deletion table for deletion information whose creation time is greater than the last deletion time; The acquisition of the recorded data includes: Obtain deletion information from the file deletion table whose creation time is greater than the last deletion time, and store the deletion information as a second array object.
7. The file synchronization method according to claim 6, characterized in that, The file synchronization based on the recorded data includes: Iterate through the deletion information in the second data object; If the physical address in the deletion information indicates that the record for the deletion information was created on the host, then the corresponding file is deleted based on the file save path in the deletion information, and the deletion information corresponding to the file is also deleted.
8. The file synchronization method according to claim 1, characterized in that, The method includes: Obtain the file synchronization information transmitted by the host, and update the stored file synchronization data table based on the file synchronization information, wherein the file synchronization information is sent by the host when performing file upload and / or file deletion operations; or If a file upload and / or file deletion operation is detected, corresponding file synchronization information is generated and sent to the host to update the file synchronization data table.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method as described in any one of claims 1-8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed, it implements the steps of the method as described in any one of claims 1-8.
Citation Information
Patent Citations
Method and system for deleting and synchronizing files of main and standby servers
CN117891783A
Data synchronization method and device, equipment and medium
CN119537470A