A file synchronization method, system, electronic device and storage medium
Patent Information
- Application Number
- CN202211731966.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2042-12-30
AI Technical Summary
[0004]然而,在一些大文件的传输场景中,由于文件过大或同步设备性能较差,在一次扫描周期内可能未完成对文件的拷贝,此时,同步设备会将已经扫描得到的变化数据进行传输,而由于大文件未拷贝完成,进行传输的大文件可能不完整,从而导致同步文件的可靠性和准确性受影响,同时,对不完整的文件进行传输,会导致设备的带宽浪费
[0007] In this embodiment, the file to be synchronized is first determined, and its status is also determined. When the file status indicates that the processing of the file to be synchronized is complete, the file to be synchronized is then synchronized with the receiving end. This reduces the number of files that have not been processed and are sent to the receiving end for synchronization, improving the accuracy and integrity of file transmission. Simultaneously, reducing the transmission of files that have not been processed reduces the repeated transmission of files after processing is complete, thereby reducing the bandwidth consumption caused by repeated transmissions of files to be synchronized.
Smart Images

Figure CN116319826B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data transmission, and more specifically, to a file synchronization method, system, electronic device, and storage medium. Background Technology
[0002] When performing data transfer, it is usually necessary to transfer data from one device to another to achieve data synchronization between the two devices. For example, data added, modified, or deleted in a specified location on a personal computer is synchronized to a server so that the server can adjust the corresponding data.
[0003] In some real-time synchronization scenarios, it is necessary to ensure the timeliness of data synchronization between two devices. Changes in the synchronizing device need to be transmitted to the synchronized device in a timely manner. Currently, a scanning cycle is usually set to scan the changed data in the synchronizing device at a certain frequency. After a scanning cycle is completed, the synchronizing device will transmit the scanned changed data to the synchronized device for synchronization.
[0004] However, in some large file transfer scenarios, due to the large size of the file or the poor performance of the synchronization device, the file copy may not be completed in one scan cycle. In this case, the synchronization device will transmit the scanned changes. Since the large file has not been copied, the transmitted large file may be incomplete, which will affect the reliability and accuracy of the synchronized file. At the same time, transmitting incomplete files will lead to a waste of the device's bandwidth. Summary of the Invention
[0005] In view of this, this application provides a file synchronization method, system, electronic device, and storage medium to improve the accuracy and integrity of file synchronization and reduce the waste of device transmission bandwidth.
[0006] In a first aspect, embodiments of this application provide a file synchronization method, comprising: determining a file to be synchronized, wherein the file to be synchronized is a file that has changed in a monitoring directory; determining the file status of the file to be synchronized based on the change attributes of the file to be synchronized, wherein the change attributes are used to characterize the changes in the file to be synchronized; and synchronizing the file to be synchronized with a receiving end when the file status indicates that the processing of the file to be synchronized is completed.
[0007] In this embodiment, the file to be synchronized is first determined, and its status is also determined. When the file status indicates that the processing of the file to be synchronized is complete, the file to be synchronized is then synchronized with the receiving end. This reduces the number of files that have not been processed and are sent to the receiving end for synchronization, improving the accuracy and integrity of file transmission. Simultaneously, reducing the transmission of files that have not been processed reduces the repeated transmission of files after processing is complete, thereby reducing the bandwidth consumption caused by repeated transmissions of files to be synchronized.
[0008] In one embodiment, determining the file to be synchronized includes: scanning the files in the monitoring directory based on a preset period; and determining the changed file as the file to be synchronized when it is determined that the files in the monitoring directory have changed in two adjacent periods.
[0009] In this embodiment, files in the monitoring directory are scanned at a preset period, thereby periodically identifying files to be synchronized and improving the real-time synchronization with the receiving end.
[0010] In one embodiment, the change attribute includes a change type, and determining the file status of the file to be synchronized based on the change attribute of the file to be synchronized includes: determining the change type of the file to be synchronized, wherein the change type includes addition, deletion, and modification; and determining the file status of the file to be synchronized based on a preset relationship between the change type and the file status, and the change type of the file to be synchronized.
[0011] In this embodiment of the application, the file status of the file to be synchronized can be determined by the change type, thereby simplifying the process of determining the file status, improving the efficiency of determining the file status, and thus improving the efficiency of file synchronization.
[0012] In one embodiment, determining the file status of the file to be synchronized based on the preset relationship between the change type and the file status, and the change type of the file to be synchronized, includes: determining that when the change type of the file to be synchronized is deletion, the file status of the file to be synchronized is a state indicating that the processing of the file to be synchronized is completed; correspondingly, synchronizing the file to be synchronized with the receiving end includes: sending a deletion instruction to the receiving end, the deletion instruction being used to instruct the receiving end to delete the file to be synchronized.
[0013] In this embodiment of the application, for files to be synchronized that are to be deleted, since there is no need to process or copy the files, the file status of the files to be synchronized can be directly determined as a status indicating that the processing of the files to be synchronized is complete, and a deletion command can be sent to the receiving end to delete the files to be synchronized. This simplifies the process of confirming the file status and improves the efficiency of file synchronization.
[0014] In one embodiment, determining the file status of the file to be synchronized based on the preset relationship between the change type and the file status, and the change type of the file to be synchronized, includes: when it is determined that the change type of the file to be synchronized is addition or modification, determining the data volume of the file to be synchronized; when it is determined that the data volume of the file to be synchronized is less than a preset data threshold, determining the file status of the file to be synchronized as a state indicating that the processing of the file to be synchronized is completed.
[0015] In this embodiment, the preset data threshold can, to some extent, characterize the amount of data that the device can process within a preset period. When it is determined that the change type of the file to be synchronized is addition or modification, the data volume of the file to be synchronized can be determined and compared with the preset data threshold. If the data volume of the file to be synchronized is less than the preset data threshold, the device can ensure that it can complete the processing of the file to be synchronized. By comparing the data volume of the file to be synchronized with the preset data threshold, the processing status of the file to be synchronized can be determined relatively quickly, thereby determining the file status of the file to be synchronized relatively quickly and improving the synchronization efficiency of the file to be synchronized.
[0016] In one embodiment, the change attribute includes a time change attribute. Determining the file status of the file to be synchronized based on the change attribute includes: when it is determined that the data volume of the file to be synchronized is greater than a preset data threshold, acquiring the time change attribute of the file to be synchronized, the time change attribute including the discovery time and the modification time of the file to be synchronized; comparing the time difference between the discovery time and the modification time with a preset temporary storage duration; when it is determined that the time difference is greater than the preset temporary storage duration, determining that the file status of the file to be synchronized is a state representing the completion of the processing of the file to be synchronized.
[0017] In this embodiment, the time difference between the discovery time and the modification time represents the processing time already elapsed for the file to be synchronized. When the time difference is greater than a preset temporary storage period, it indicates that the file to be synchronized has undergone a relatively long processing period. Therefore, the file status of the file to be processed can be determined by judging whether the time difference between the discovery time and the modification time is greater than the preset temporary storage period. By comparing the time difference with the preset temporary storage period, the file to be synchronized can be allowed sufficient time for processing, thereby reducing the possibility of the file not being processed in time and improving the accuracy of file synchronization.
[0018] In one embodiment, there are multiple files to be synchronized. Before comparing the time difference between the discovery time and the modification time with the preset storage duration, the method further includes: determining the preset storage duration based on the hardware configuration of the device where the files to be synchronized are located, and / or the proportion of files to be synchronized with a data volume greater than a preset data threshold to all the files to be synchronized.
[0019] In this embodiment, the preset storage time is determined based on the hardware configuration of the device where the file to be synchronized is located, and / or the proportion of files to be synchronized with a data volume greater than a preset data threshold to all files to be synchronized. This makes the determined preset storage time more in line with the needs of each device or each actual scenario, thereby making the file status determined based on the preset storage time more accurate, reducing the occurrence of files to be synchronized not being processed, and thus improving the integrity and accuracy of the files.
[0020] Secondly, embodiments of this application provide a file synchronization system, comprising: a synchronization terminal, configured to execute the file synchronization method as described in any of the first aspects; and a receiving terminal, communicatively connected to the synchronization terminal, wherein the receiving terminal is configured to synchronize with the file to be synchronized by the synchronization terminal.
[0021] Thirdly, embodiments of this application provide an electronic device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor performs the file synchronization method as described in the first aspect.
[0022] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the file synchronization method as described in the first aspect. Attached Figure Description
[0023] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 A schematic diagram of a file synchronization system provided in an embodiment of this application;
[0025] Figure 2 A flowchart illustrating a file synchronization method provided in one embodiment of this application;
[0026] Figure 3 A schematic diagram of a file synchronization device provided in an embodiment of this application;
[0027] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0028] Icons: Synchronization end 110; Receiver end 120; File synchronization device 200; Scanning module 210; Status module 220; Synchronization module 230; Electronic device 300; Processor 310; Memory 320. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0030] Before explaining this application, let me first explain the scenario to which this application is applied.
[0031] When synchronizing files between different devices, such as synchronizing files on device A with files on device B, the files from device A are usually copied to device B so that device B has the same files as device A. During synchronization, typically only the changed files are synchronized to improve efficiency. For example, if one file on device A is modified while the rest remain unchanged, only the modified file is synchronized to device B.
[0032] Currently, to improve the timeliness of file synchronization between devices, a scanning cycle is set to periodically scan the files. For example, the files on device A are scanned every second to determine if there are any changes on device A. If changes have occurred, the changed files are copied and then sent to device B.
[0033] However, files vary in size, and devices have varying performance levels. Different devices have different copying efficiencies for the same file, and the same device has different copying efficiencies for different files. For example, device A takes different amounts of time to copy a 10MB file compared to a 1GB file. Similarly, for a 10MB file, a higher-performance device will copy it faster than a lower-performance device. With a fixed scan cycle, if larger files change, a device with a fixed performance might not be able to complete the copy within that cycle. At the end of the current scan cycle or the beginning of the next, the device will send the already copied content to other devices, resulting in incomplete file synchronization and wasted bandwidth. For instance, device A might copy a 500MB file in one second, but it cannot completely copy a 1GB file. At the end of the scan cycle, it will send the 500MB file to device B. Since the file sent by device A is incomplete, device B cannot accurately synchronize with device A.
[0034] In view of the above situation, this application provides a file synchronization method, system, electronic device and storage medium, so as to synchronize the complete file to other devices after determining that the file adjustment is completed.
[0035] Please see Figure 1 , Figure 1 This is a schematic diagram of a file synchronization system provided in an embodiment of this application. The file synchronization system includes: a synchronization terminal 110 and a receiving terminal 120.
[0036] The synchronizing end 110 and the receiving end 120 are different electronic devices, such as computers, mobile phones, servers, etc. The types of electronic devices used by the synchronizing end 110 and the receiving end 120 can be the same or different. For example, the synchronizing end 110 can be a user's personal computer, and the receiving end 120 can be a server or a personal computer not connected to the synchronizing end 110.
[0037] The synchronization terminal 110 is communicatively connected to the receiving terminal 120. The synchronization terminal 110 can transmit files or send control commands to the receiving terminal 120. In the data transfer process, there are usually a data sender and a data receiver. In this application, the synchronization terminal 110 can be the sender in the data transfer, and the receiving terminal 120 can be the receiver in the data transfer.
[0038] The synchronization terminal 110 has at least one storage area for storing files. The synchronization terminal 110 monitors the storage area and synchronizes the changed files with the receiving terminal 120 when the files in the storage area change.
[0039] For example, when a new file is added to the storage area, the synchronization terminal 110 copies the new file and sends it to the receiving terminal 120. The receiving terminal 120 receives the new file and stores it in a preset location. When a file is deleted from the storage area of the synchronization terminal 110, the synchronization terminal 110 sends a file deletion instruction to the receiving terminal, and the receiving terminal 120 deletes the corresponding file upon receiving the instruction. Furthermore, when a file in the storage area is modified, the synchronization terminal 110 copies the modified file and sends it to the receiving terminal, which can then use the modified file to replace the original stored file.
[0040] The synchronization terminal 110 is used to execute the file synchronization method provided in this application. The file synchronization method provided in this application will be described below.
[0041] Please see Figure 2 , Figure 2 This is a flowchart illustrating a file synchronization method provided in an embodiment of this application. The file synchronization method includes:
[0042] S110, Select the file to be synchronized.
[0043] In this embodiment, the files to be synchronized are those that have changed in the monitoring directory, which is the file directory of the monitored storage area in the synchronization terminal. "Changed" refers to whether, at a certain moment compared to a previous moment, the files in the monitoring directory have undergone changes such as addition, deletion, or modification.
[0044] The addition or deletion of files can be determined by changes in the number of files in the monitoring directory. For example, if the monitoring directory originally contained 10 files, and the number decreases to 9, it indicates that files have been deleted, and these deleted files are awaiting synchronization. Similarly, if the number increases from 10 to 11, it indicates that files have been added, and these newly added files are awaiting synchronization. Modifications to files can be determined by different file attributes. For example, the file's size can be used to determine modification. If a file was originally 10KB, and its size changes to a size other than 10KB, it indicates that the file has been modified.
[0045] In some embodiments, the modification time of a file can also be used to determine whether the file has changed. It is understood that electronic devices usually record the creation time, modification time, etc. of files. In this case, the modification time of the same file can be compared between the synchronization end and the receiving end to determine whether the modification time is the same, thereby determining whether the file has changed.
[0046] In one embodiment, determining the file to be synchronized includes: scanning the files in the monitoring directory based on a preset period; and when it is determined that the files in the monitoring directory have changed in two adjacent periods, the changed files are determined as the files to be synchronized.
[0047] Since changes to files on the synchronizing end need to be synchronized with the receiving end in a timely manner, a certain period can be preset to periodically scan the files in the monitoring directory to determine whether the files in the monitoring directory have changed. For example, the preset period can be 1 second, 2 seconds, etc., and the preset period can be set according to the device performance of the synchronizing end or the real-time requirements of the synchronization. The above is only an example and should not be construed as a limitation of this application. The scanned content can include information such as the number of files, the modification time of different files, and the data size.
[0048] By scanning the files in the monitored directory, scan results can be obtained. In this embodiment, the scan results of two adjacent cycles can be compared. If the scan results of a later cycle differ from those of an earlier cycle, a change can be identified. Then, the changed files can be determined based on the content of the scan results, i.e., the files to be synchronized can be identified. Simultaneously with identifying the files to be synchronized, the type of change can also be determined, which can be the aforementioned addition, deletion, or modification.
[0049] In some embodiments, the monitoring directory also includes a record file information table, which records the changes of all files in the monitoring directory. During scanning, the record file information table can also be scanned to determine the changes of all files, thereby identifying the files to be synchronized.
[0050] S120, determine the file status of the file to be synchronized based on the changed attributes of the file to be synchronized.
[0051] The change attributes of the files to be synchronized can include the type of change, the size of the file data, and the time change attribute. The change type can be one of the aforementioned additions, deletions, and deletions. The file size change can be the file size or whether the file has changed compared to its previous state. The time change attribute can include creation time, modification time, and other time-related information.
[0052] The file status indicates whether the file has been processed by the synchronization end. For example, if the synchronization end has completed copying the file to be synchronized, it can be determined that the synchronization end has completed processing the file and it can be transmitted to the receiving end for synchronization.
[0053] In one embodiment, the file status of the file to be synchronized can be determined based on a preset relationship between change type and file status, and the change type of the file to be synchronized.
[0054] In this embodiment, the preset relationship between change type and file status may include deleting the preset relationship with file status, and adding or deleting the preset relationship with file status.
[0055] When the change type of the file to be synchronized is determined to be deletion, the synchronizing end does not need to copy the file or transfer any file to the receiving end. At this point, it can be directly determined that the synchronizing end has completed processing of the file to be synchronized. Therefore, the file status of the file to be synchronized can be determined directly by judging whether the change type is deletion. That is, when the change type of the file to be synchronized is determined to be deletion, the file status of the file to be synchronized is determined to be a state indicating that the processing of the file to be synchronized is complete.
[0056] When the change type of the file to be synchronized is determined to be addition or modification, the synchronizing end needs to copy the added or modified file. The copying process takes varying amounts of time depending on the synchronizing end's device performance and the file size. Different files may be copied completely within a preset period, while some files may not be copied at all. Therefore, in this embodiment, when the change type of the file to be synchronized is determined to be addition or modification, the file status cannot be directly obtained. Instead, the file status can be determined by the file size (i.e., the amount of data in the file to be synchronized).
[0057] In one embodiment, the process of determining the file status based on the change type and data volume of the file to be synchronized includes: when it is determined that the change type of the file to be synchronized is addition or modification, determining the data volume of the file to be synchronized; when it is determined that the data volume of the file to be synchronized is less than a preset data threshold, determining the file status of the file to be synchronized to be a status indicating that the processing of the file to be synchronized is completed.
[0058] Different files to be synchronized may have different amounts of data. For example, some files may have a small amount of data, which the synchronization end may be able to process in a short time, while some files may have a large amount of data, which the synchronization end may need to spend more time copying.
[0059] In this embodiment, a data threshold can be preset, i.e., a pre-defined data threshold, to characterize the amount of data that the synchronization end can process within a preset period. Then, the data volume of the file to be synchronized is obtained and compared with the preset data threshold. When the data volume of the file to be synchronized is less than the preset data threshold, it indicates that the synchronization end can complete the copying of the file. Therefore, after completing the scan within the preset period, the file to be synchronized can be sent to the receiving end. For example, if the synchronization end can complete the copying of a 1KB file in a short time, then the file can be copied within the preset period, and the file can be sent to the receiving end after the copying is complete. Therefore, when the data volume of the file to be synchronized is less than the preset data threshold, the file status of the file to be synchronized is determined to be a state indicating that the processing of the file to be synchronized is complete.
[0060] The data volume of the files to be synchronized can be obtained by scanning the files in the monitoring directory. The preset data threshold can be reasonably set according to the performance of the synchronization device. For example, if the synchronization device has superior processing performance, the preset data threshold can be set to 20MB, 30MB, etc.; if the synchronization device has poor processing performance, the preset data threshold can be set to 5MB, 10MB, etc. The above are merely examples and should not be construed as limiting the scope of this application.
[0061] When the amount of data in the file to be synchronized exceeds the preset data threshold, it indicates that the synchronization end cannot completely copy the file to be synchronized within one scan cycle. In this case, the file status of the file to be synchronized can be determined as an incomplete processing status within the current scan cycle.
[0062] In one embodiment, when it is determined that the amount of data in the file to be synchronized is greater than a preset data threshold, the time change attributes of the file to be synchronized can be obtained. The time change attributes include the discovery time and the modification time of the file to be synchronized. Then, the time difference between the discovery time and the modification time is compared with a preset temporary storage time. Finally, when it is determined that the time difference is greater than the preset temporary storage time, the status of the file to be synchronized is determined to be the state where the file to be synchronized has been processed.
[0063] In this embodiment, the time change attribute can include the discovery time and modification time of the file to be synchronized. The modification time of the file to be synchronized is the time recorded by the synchronization end after the file is modified, which can be viewed and obtained in the attributes of the file to be synchronized. The discovery time of the file to be synchronized refers to the time when the changed files in the monitored directory are discovered during the scan of the monitored directory.
[0064] It is understandable that when the amount of data in the file to be synchronized is greater than the preset data threshold, the file to be synchronized cannot be copied within one scan cycle. Synchronization can be performed after the file to be synchronized is copied. In this embodiment, a preset storage time can be set to wait for the synchronization end to complete the copying of the file to be synchronized.
[0065] In one embodiment, there are multiple files to be synchronized, and the preset storage time can be determined based on the hardware configuration of the device where the files to be synchronized are located, and / or the proportion of files to be synchronized with a data volume greater than a preset data threshold to all files to be synchronized.
[0066] In this embodiment, the synchronization end is the device where the file to be synchronized is located. When the performance of the synchronization end is better, the copying efficiency of the file to be synchronized is higher. In this case, a shorter preset storage time can be set. For example, if the performance of device 1 is better than that of device 2, and the preset storage time of device 2 is set to 10 seconds, the preset storage time of device 1 can be set to 8 seconds, 5 seconds, etc.
[0067] In this embodiment, there may be multiple files in the monitoring directory. Furthermore, these files may change; any file could be a file to be synchronized, and different files may have different sizes. Due to the limited performance of the synchronization device, when multiple files with data sizes exceeding a preset data threshold need to be copied, the copying of different files may interfere with each other. Therefore, when the proportion of files with data sizes exceeding the preset data threshold is large, the preset temporary storage time can be appropriately increased; conversely, when the proportion is small, the preset temporary storage time can be appropriately decreased.
[0068] It is understood that the preset temporary storage time can be determined individually or jointly based on the hardware configuration of the device where the file to be synchronized is located and the proportion of the file to be synchronized whose data volume is greater than the preset data threshold. The above is only an example and should not be construed as a limitation of this application.
[0069] The time difference obtained by subtracting the modification time from the discovery time is the time elapsed since the file to be synchronized was modified, i.e., the time for copying before synchronization. When this time difference is greater than the preset temporary storage time, it indicates that the file to be synchronized has been copied for a relatively long time, and can be regarded as the file to be synchronized having been copied. Therefore, the file status of the file to be synchronized can be determined as the file status indicating that the processing of the file to be synchronized has been completed.
[0070] S130: When the file status indicates that the file to be synchronized has been processed, the file to be synchronized is synchronized with the receiving end.
[0071] For files to be synchronized that have been added or modified, the file status can be determined using the above method. When the file status indicates that the file synchronization process is complete, it means that the file has been completely copied. At this point, the file can be sent to the receiving end for storage, thereby achieving file synchronization between the synchronizing end and the receiving end.
[0072] For files to be synchronized that have a change type of deletion, after determining the change type, a deletion command can be sent to the receiving end. The deletion command is used to instruct the receiving end to delete the file to be synchronized, thereby achieving file synchronization between the synchronizing end and the receiving end.
[0073] In this embodiment, the file to be synchronized is first determined, and its status is also determined. When the file status indicates that the processing of the file to be synchronized is complete, the file to be synchronized is then synchronized with the receiving end. This reduces the number of files that have not been processed and are sent to the receiving end for synchronization, improving the accuracy and integrity of file transmission. Simultaneously, reducing the transmission of files that have not been processed reduces the repeated transmission of files after processing is complete, thereby reducing the bandwidth consumption caused by repeated transmissions of files to be synchronized.
[0074] Based on the same inventive concept, embodiments of this application also provide a file synchronization device. Please refer to... Figure 3 , Figure 3 This is a schematic diagram of a file synchronization device provided in an embodiment of this application. The file synchronization device 200 includes: a scanning module 210, a status module 220, and a synchronization module 230.
[0075] The scanning module 210 is used to determine the files to be synchronized, which are the files that have changed in the monitored directory.
[0076] The status module 220 is used to determine the file status of the file to be synchronized based on the change attributes of the file to be synchronized. The change attributes are used to characterize the changes of the file to be synchronized.
[0077] The synchronization module 230 is used to synchronize the file to be synchronized with the receiving end when the file status indicates that the processing of the file to be synchronized is complete.
[0078] The scanning module 210 is also used to scan the files in the monitoring directory based on a preset period; when it is determined that the files in the monitoring directory have changed in two adjacent periods, the changed files are identified as files to be synchronized.
[0079] The status module 220 is also used to determine the change type of the file to be synchronized, including addition, deletion and modification; based on the preset relationship between change type and file status and the change type of the file to be synchronized, the file status of the file to be synchronized is determined.
[0080] The status module 220 is also used to determine the file status of the file to be synchronized to a state indicating that the synchronization of the file is complete when the change type of the file to be synchronized is deletion. The synchronization module 230 is also used to send a deletion command to the receiving end, which instructs the receiving end to delete the file to be synchronized.
[0081] The status module 220 is also used to determine the amount of data in the file to be synchronized when the change type of the file to be synchronized is determined to be addition or modification; and to determine the file status of the file to be synchronized to a state indicating that the processing of the file to be synchronized is completed when the amount of data in the file to be synchronized is determined to be less than a preset data threshold.
[0082] The status module 220 is also used to obtain the time change attributes of the file to be synchronized when it is determined that the amount of data of the file to be synchronized is greater than a preset data threshold. The time change attributes include the discovery time of the file to be synchronized and the modification time of the file to be synchronized. The time difference between the discovery time and the modification time is compared with a preset temporary storage time. When it is determined that the time difference is greater than the preset temporary storage time, the status of the file to be synchronized is determined to be a state that represents the completion of the processing of the file to be synchronized.
[0083] The status module 220 is also used to determine the preset storage duration based on the hardware configuration of the device where the file to be synchronized is located, and / or the proportion of the files to be synchronized with a data volume greater than a preset data threshold to all files to be synchronized.
[0084] It is understood that the file synchronization device corresponds to the aforementioned file synchronization method. The specific implementation details can be found in the file synchronization method and will not be elaborated upon here. The aforementioned file synchronization device and method can be implemented as a computer-readable instruction. This computer-readable instruction can be implemented in, for example... Figure 4 It runs on the electronic device shown.
[0085] Please refer to Figure 4 This application also provides an electronic device 300, which can serve as the execution subject of the aforementioned file synchronization method, including: a processor 310 and a memory 320 communicatively connected to the processor 310.
[0086] The memory 320 stores instructions that can be executed by the processor 310. The processor 310 executes the instructions to enable the processor 310 to perform the file synchronization method in the aforementioned embodiments.
[0087] The processor 310 and memory 320 can be connected via a communication bus, or via communication modules such as wireless communication modules, Bluetooth communication modules, 4G / 5G communication modules, etc.
[0088] Processor 310 can be an integrated circuit chip with signal processing capabilities. Processor 310 can be a general-purpose processor, including a CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be a digital signal processor, application-specific integrated circuit, off-the-shelf programmable gate array, or other programmable logic device or transistor logic device, or discrete hardware component. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor.
[0089] The memory 320 may include, but is not limited to, RAM (Random Access Memory), ROM (Read Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0090] It is understood that the electronic device 300 may also include more general modules required by itself, which will not be described one by one in the embodiments of this application.
[0091] Based on the same inventive concept, embodiments of this application also provide a computer-readable storage medium storing a computer program thereon, which executes the methods provided in the above embodiments when the computer program is run.
[0092] The storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., SSDs (Solid State Disks)).
[0093] In the embodiments provided in this application, it should be understood that the disclosed methods and apparatus can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. The functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0094] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM (Read-Only Memory), RAM (Random Access Memory), magnetic disks, or optical disks.
[0095] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0096] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A file synchronization method, characterized in that, include: Identify the files to be synchronized, which are files that have changed in the monitored directory; The file status of the file to be synchronized is determined based on the change attributes of the file to be synchronized, and the change attributes are used to characterize the changes of the file to be synchronized. When the file status indicates that the processing of the file to be synchronized is complete, the file to be synchronized is synchronized with the receiving end; The change attributes include time change attributes. Determining the file status of the file to be synchronized based on the change attributes of the file to be synchronized includes: when it is determined that the data volume of the file to be synchronized is greater than a preset data threshold, acquiring the time change attributes of the file to be synchronized, the time change attributes including the discovery time and the modification time of the file to be synchronized; comparing the time difference between the discovery time and the modification time with a preset temporary storage duration; when it is determined that the time difference is greater than the preset temporary storage duration, determining that the file status of the file to be synchronized is a state indicating that the processing of the file to be synchronized is complete; The number of files to be synchronized is multiple. Before comparing the time difference between the discovery time and the modification time with the preset storage duration, the method further includes: determining the preset storage duration based on the hardware configuration of the device where the files to be synchronized are located, and / or the proportion of files to be synchronized with a data volume greater than a preset data threshold to all the files to be synchronized.
2. The method according to claim 1, characterized in that, The process of determining the file to be synchronized includes: The files in the monitored directory are scanned according to a preset period; When it is determined that the files in the monitoring directory have changed in two adjacent cycles, the changed files are identified as the files to be synchronized.
3. The method according to claim 2, characterized in that, The change attributes include change type, and determining the file status of the file to be synchronized based on the change attributes of the file to be synchronized includes: Determine the change type of the file to be synchronized, including additions, deletions, and modifications; Based on the preset relationship between the change type and the file status, and the change type of the file to be synchronized, the file status of the file to be synchronized is determined.
4. The method according to claim 3, characterized in that, The step of determining the file status of the file to be synchronized based on the preset relationship between the change type and the file status, and the change type of the file to be synchronized, includes: when the change type of the file to be synchronized is deletion, determining the file status of the file to be synchronized to be a state indicating that the processing of the file to be synchronized is completed; Correspondingly, synchronizing the file to be synchronized with the receiving end includes: sending a deletion instruction to the receiving end, the deletion instruction being used to instruct the receiving end to delete the file to be synchronized.
5. The method according to claim 3, characterized in that, Based on the preset relationship between the change type and the file status, and the change type of the file to be synchronized, the file status of the file to be synchronized is determined, including: when it is determined that the change type of the file to be synchronized is addition or modification, the data volume of the file to be synchronized is determined. When it is determined that the amount of data in the file to be synchronized is less than a preset data threshold, the file status of the file to be synchronized is determined to be a status that indicates that the processing of the file to be synchronized is complete.
6. A file synchronization system, characterized in that, include: A synchronization endpoint, used to execute the file synchronization method as described in any one of claims 1-5; The receiving end is communicatively connected to the synchronization end, and is used to synchronize the file to be synchronized with the synchronization end.
7. An electronic device, characterized in that, The method includes a memory and a processor, wherein the memory stores computer-readable instructions that, when executed by the processor, cause the processor to perform the method as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The readable storage medium stores a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1-5.
Citation Information
Patent Citations
File synchronisation method and device
CN101281543A
File synchronization method, file synchronization server and storage medium
CN111654522A
Method and device for monitoring file increment synchronization based on directory
CN115203152A