CN116319826A - File synchronization method, system, electronic equipment and storage medium - Google Patents

File synchronization method, system, electronic equipment and storage medium Download PDF

Info

Publication number
CN116319826A
CN116319826A CN202211731966.3A CN202211731966A CN116319826A CN 116319826 A CN116319826 A CN 116319826A CN 202211731966 A CN202211731966 A CN 202211731966A CN 116319826 A CN116319826 A CN 116319826A
Authority
CN
China
Prior art keywords
file
synchronized
determining
files
change
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
CN202211731966.3A
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 Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software 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 Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202211731966.3A priority Critical patent/CN116319826A/en
Publication of CN116319826A publication Critical patent/CN116319826A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a file synchronization method, a system, electronic equipment and a storage medium, and relates to the field of data transmission. The file synchronization method comprises the following steps: determining a file to be synchronized, wherein the file to be synchronized is a file which changes under a monitoring directory; determining a file state of the file to be synchronized based on a change attribute of the file to be synchronized, wherein the change attribute is used for representing the change condition of the file to be synchronized; and synchronizing the file to be synchronized with a receiving end when determining that the file state characterizes the completion of the file processing to be synchronized. And synchronizing the processed file to be synchronized with the receiving end by determining the file state of the file to be synchronized, so that the transmission of the file which is not processed is reduced, and the integrity and accuracy of file transmission are improved.

Description

File synchronization method, system, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data transmission, and in particular, to a file synchronization method, system, electronic device, and storage medium.
Background
When data ferrying is performed, data of one device is usually required to be transmitted to another device, so that data synchronization between the two devices is realized, for example, newly added, modified or deleted data at a designated position on a personal computer is synchronized to a server, so that the server adjusts corresponding data.
In some real-time synchronization scenarios, timeliness of data synchronization between two devices needs to be guaranteed, data changed in a synchronization device needs to be transmitted to a synchronized device in time, at present, a scanning period is generally set, the data changed in the synchronization device is scanned at a certain frequency, and after one scanning period is finished, the synchronization device transmits the scanned data changed to the synchronized device for synchronization.
However, in some large file transmission scenarios, due to the fact that the file is too large or the performance of the synchronization device is poor, copying of the file may not be completed in one scanning period, at this time, the synchronization device may transmit the changed data obtained by scanning, and due to the fact that the large file is not copied, the large file to be transmitted may not be completed, so that reliability and accuracy of the synchronization file are affected, and meanwhile, bandwidth waste of the device may be caused when the incomplete file is transmitted.
Disclosure of Invention
In view of this, the present application provides a method, a system, an electronic device, and a storage medium for file synchronization, so as to improve accuracy and integrity of file synchronization and reduce waste of transmission bandwidth of the device.
In a first aspect, an embodiment of the present application provides a file synchronization method, including: determining a file to be synchronized, wherein the file to be synchronized is a file which changes under a monitoring directory; determining a file state of the file to be synchronized based on a change attribute of the file to be synchronized, wherein the change attribute is used for representing the change condition of the file to be synchronized; and synchronizing the file to be synchronized with a receiving end when determining that the file state characterizes the completion of the file processing to be synchronized.
In the embodiment of the application, the file to be synchronized is determined first, the state of the file to be synchronized is determined, and when the file state characterizes that the processing of the file to be synchronized is completed, the file to be synchronized is synchronized with the receiving end, so that the transmission of the file which is not processed to the receiving end can be reduced, and the accuracy and the integrity of file transmission are improved. Meanwhile, the transmission of the files which are not processed is reduced, so that the repeated transmission of the files after the processing is completed can be reduced, and the occupation of the bandwidth caused by the repeated transmission of the files to be synchronized is reduced.
In an embodiment, the determining the file to be synchronized includes: scanning the files under the monitoring directory based on a preset period; and when the files under the monitoring directory are determined to be changed in two adjacent periods, determining the changed files as the files to be synchronized.
In the embodiment of the application, the files under the monitoring directory are scanned through the preset period, so that the files to be synchronized are determined periodically, and the instantaneity of synchronizing the files with the receiving end is improved.
In an embodiment, the change attribute includes a change type, and the determining the file state 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 comprises addition, deletion and modification; and determining the file state of the file to be synchronized based on the preset relation between the change type and the file state and the change type of the file to be synchronized.
In the embodiment of the application, the file state of the file to be synchronized can be determined through the change type, so that the process of determining the file state can be simplified, the efficiency of determining the file state is improved, and the efficiency of file synchronization is further improved.
In an embodiment, the determining the file state of the file to be synchronized based on the preset relationship between the change type and the file state and the change type of the file to be synchronized includes: when the change type of the file to be synchronized is determined to be deleted, determining the file state of the file to be synchronized as a state representing that the processing of the file to be synchronized is completed; correspondingly, the synchronizing the file to be synchronized with the receiving end includes: and sending a deleting instruction to the receiving end, wherein the deleting instruction is used for indicating the receiving end to delete the file to be synchronized.
In the embodiment of the application, for the file to be synchronized of the deletion type, the file state of the file to be synchronized can be directly determined to be a state representing that the processing of the file to be synchronized is completed because the processing and copying of the file are not needed, and the deletion instruction is sent to enable the receiving end to delete the file to be synchronized, so that the confirmation process of the file state can be simplified, and the efficiency of file synchronization is improved.
In an embodiment, determining the file state of the file to be synchronized based on the preset relationship between the change type and the file state and the change type of the file to be synchronized includes: when the change type of the file to be synchronized is determined to be newly added or modified, determining the data volume of the file to be synchronized; and when the data quantity of the file to be synchronized is smaller than a preset data threshold value, determining the file state of the file to be synchronized as a state representing that the processing of the file to be synchronized is completed.
In the embodiment of the present application, the preset data threshold may represent the processable data amount of the device in a preset period to a certain extent, and when determining that the change type of the file to be synchronized is new or modified, the data amount of the file to be synchronized may be determined and compared with the preset data threshold, and if the data amount of the file to be synchronized is smaller than the preset data threshold, it is ensured that the device can complete the processing of the file to be synchronized. The processing condition of the device to be synchronized can be determined more quickly by comparing the data quantity of the file to be synchronized with the preset data threshold, so that the file state of the file to be synchronized is determined more quickly, and the synchronization efficiency of the file to be synchronized is improved.
In an embodiment, the change attribute includes a time change attribute, and the determining the file state of the file to be synchronized based on the change attribute of the file to be synchronized includes: when the data volume of the file to be synchronized is determined to be larger than a preset data threshold, acquiring the time change attribute of the file to be synchronized, wherein the time change attribute comprises the discovery time of the file to be synchronized 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; and when the time difference is determined to be larger than the preset temporary storage time length, determining the file state to be synchronized as a state representing that the file processing to be synchronized is completed.
In this embodiment of the present invention, the time difference between the discovery time and the modification time may represent the processing time that has elapsed for the file to be synchronized, and when the time difference is greater than the preset temporary storage time, it represents that the file to be synchronized has elapsed for a longer time, so that the file status of the file to be processed may be determined by determining whether the time difference between the discovery time and the modification time is greater than the preset temporary storage time. By comparing the time difference with the preset temporary storage time, the file to be synchronized can be processed in enough time, so that the condition that the file to be synchronized is not processed is reduced, and the accuracy of file synchronization is improved.
In an embodiment, the files to be synchronized are plural, and before comparing the time difference between the discovery time and the modification time with a preset temporary storage duration, the method further includes: and determining the preset temporary storage duration based on the hardware configuration of the equipment where the files to be synchronized are located and/or the proportion of the files to be synchronized with the data volume larger than a preset data threshold value to all the files to be synchronized.
In the embodiment of the application, the preset temporary storage time length is determined based on the hardware configuration of the equipment where the files to be synchronized are located and/or the proportion of the files to be synchronized, the data quantity of which is larger than the preset data threshold value, to all the files to be synchronized, so that the determined preset temporary storage time length is more in line with the requirements of all the equipment or all the actual scenes, the file state determined according to the preset temporary storage time length is more accurate, the occurrence of the situation that the files to be synchronized are not processed is reduced, and the integrity and the accuracy of the files are improved.
In a second aspect, an embodiment of the present application provides a file synchronization system, including: a synchronization end, configured to perform the file synchronization method according to any one of the first aspect; the receiving end is in communication connection with the synchronizing end and is used for synchronizing the file to be synchronized with the synchronizing end.
In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, where the memory stores computer readable instructions that, when executed by the processor, cause the processor to perform the file synchronization method according to the first aspect.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having a computer program stored therein, which when run on a computer causes the computer to perform the file synchronization method according to the first aspect.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a file synchronization system according to an embodiment of the present disclosure;
FIG. 2 is a flowchart of a method for synchronizing files according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a file synchronization device according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Icon: a synchronization end 110; a receiving end 120; a file synchronization device 200; a scanning module 210; a status module 220; a synchronization module 230; an electronic device 300; a processor 310; a memory 320.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
Before describing the present application, a description is given of a scenario targeted by the present application.
In synchronizing files between different devices, for example, synchronizing a file of device a with a file of device B, the file of device a is typically copied to device B so that device B has the same file as device a. In synchronization, only the changed files are generally synchronized, so that the synchronization efficiency is improved, for example, one file of the device a is modified, and the other files are unchanged, and only the modified file is synchronized to the device B.
At present, in order to improve timeliness of file synchronization between devices, a scanning period is set to periodically scan files, for example, every 1 second of time, the files of the device a are scanned, whether the device a has file change is judged, if the file change occurs, the changed file is copied, and then the file is sent to the device B.
However, files have different sizes, devices have different capabilities, the copy efficiency of the same file by different devices and the copy efficiency of different files by the same device are different, e.g., device a takes different time to copy a 10M sized file and a 1G sized file; and for a 10M size copy rate, a better performing device will copy faster than a worse performing device. The scanning period is fixed, if some larger files are changed, the equipment with fixed performance can not finish copying in the scanning period, and when the current scanning period is ended or the next scanning period is started, the equipment can firstly send copied contents to other equipment, so that the synchronous files are incomplete, complete synchronization of the files is not realized, and the waste of the bandwidth of data transmission is caused. For example, device a completes copying a 500M-sized data file within 1 second, but for a 1G-sized file, the end of the scanning period will send the 500M-sized data file to device B, where the file sent by device a is incomplete, and device B cannot accurately synchronize with device a.
In view of the above, the present application provides a file synchronization method, system, electronic device, and storage medium, so as to synchronize a complete file to other devices after determining that file adjustment is completed.
Referring to fig. 1, fig. 1 is a schematic diagram of a file synchronization system according to an embodiment of the present application. The file synchronization system includes: a synchronization end 110 and a receiving end 120.
The synchronization end 110 and the receiving end 120 are different electronic devices, for example, the synchronization end 110 and the receiving end 120 may be a computer, a mobile phone, a server, etc. The electronic device types of the synchronization end 110 and the receiving end 120 may be the same or different. For example, the synchronization end 110 may be a personal computer of a user, and the receiving end 120 may be a personal computer of a server or the non-synchronization end 110.
The synchronization end 110 is communicatively connected to the receiving end 120, and the synchronization end 110 may transmit a file to the receiving end 120 or send a control instruction for the file. In the data ferrying process, a sender and a receiver of data are generally included, and in this application, the synchronization end 110 may be the sender in the data ferrying, and the receiver end 120 may be the receiver of the data ferrying.
At least one storage area for storing files is present in the synchronization end 110, the synchronization end 110 monitors the storage area, and when the files in the storage area change, the changed files are synchronized with the receiving end 120.
For example, the storage area is newly added with a file, the synchronization end 110 copies the newly added file and sends the newly added file to the receiving end 120, and the receiving end 120 receives the newly added file and stores the newly added file in a preset position. When the file deletion exists in the storage area of the synchronization end 110, the synchronization end 110 feeds back an instruction for file deletion to the receiving end, and the receiving end 120 deletes the corresponding file after receiving the instruction. And when the file in the storage area is modified, the synchronization end 110 copies the modified file and sends the file to the receiving end, and the receiving end 120 can replace the original stored file by using the modified file.
The synchronization end 110 is configured to execute the file synchronization method provided in the present application, and next, the file synchronization method provided in the present application will be described.
Referring to fig. 2, fig. 2 is a flowchart of a file synchronization method according to an embodiment of the present application, where the file synchronization method includes:
s110, determining the file to be synchronized.
In this embodiment, the file to be synchronized is a file that changes under a monitoring directory, where the monitoring directory is a file directory of a monitored storage area in the synchronization end. The change means that whether the file under the monitoring directory changes such as new addition, deletion, modification and the like or not is monitored at a certain moment compared with the prior moment.
The addition or deletion of files may be determined by monitoring changes in the number of files in the directory. For example, if the number of the 10 files originally existing in the monitoring directory is changed to 9, the number of the files is reduced, which indicates that file deletion occurs, and the deleted files are files to be synchronized; similarly, when the number is changed from 10 to 11, the number of files is increased, and a new file is added, and the newly added file is a file to be synchronized. The modification to the file may be determined by different attributes of the file. For example, the data size of the file is determined, and when the size of the file becomes other than 10KB, the file is modified.
In some embodiments, whether the file changes may be determined by the modification time of the file, and it may be understood that in an electronic device, the creation time, the modification time, and the like of the file are generally recorded, where the modification time of the same file may be compared by the synchronization end and the receiving end, and whether the modification time is the same may be determined, so as to determine whether the file changes.
In one embodiment, determining a file to be synchronized includes: scanning the files under the monitoring directory based on a preset period; and when the files under the monitoring directory are determined to change in two adjacent periods, determining the changed files as files to be synchronized.
Because the file change of the synchronous end needs to be synchronized with the receiving end in time, a certain period can be preset, the files under the monitoring directory are scanned regularly, and whether the files under the monitoring directory are changed or not is judged. Illustratively, the preset period may be 1 second, 2 seconds, etc., and the preset period may be set according to the device performance of the synchronization end or the real-time requirement of synchronization, which is only an example and should not be construed as a limitation of the present application. The scanned content can be information such as the number of files, the respective modification time of different files, the size of the data volume and the like.
The scan result can be obtained by scanning the file under the monitoring directory, in this embodiment, the scan results of two adjacent periods can be compared, and if the scan result of the subsequent period is changed compared with the scan result of the previous period, the change can be determined. Then, the changed file, that is, the file to be synchronized, can be determined by scanning the content of the result. The change type of the file to be synchronized can be determined while the file to be synchronized is determined, and the change type can be the new addition, deletion and modification.
In some embodiments, the monitoring directory further includes a record file information table, where the record file information table records the change conditions of all files under the monitoring directory, and when scanning is performed, the record file information table may be scanned to determine the change conditions of all files, so as to determine the files to be synchronized.
S120, determining the file state of the file to be synchronized based on the change attribute of the file to be synchronized.
The change attribute of the file to be synchronized may be a change type of the file to be synchronized, a file data size attribute, a time change attribute, etc. The change type may be the above-mentioned addition, deletion, and reduction, and the change size of the file data amount may be the file size or whether the file has changed compared to the previous period, or the like. The time-varying attribute may be creation time, modification time, etc. information.
The file state may be a state of whether the file is processed by the synchronous side. For example, if the synchronization end completes copying the file to be synchronized, it may be determined that the processing of the file to be synchronized by the synchronization end is completed, and the file to be synchronized may be transmitted to the receiving end for synchronization.
In an embodiment, the file state of the file to be synchronized may be determined based on a preset relationship between the change type and the file state and the change type of the file to be synchronized.
In this embodiment, the preset relationship between the change type and the file state may include deleting the preset relationship between the change type and the file state, and adding or deleting the preset relationship between the change type and the file state.
When the change type of the file to be synchronized is determined to be deleted, the synchronizing terminal does not need to copy the file or transmit any file to the receiving terminal, and at this time, the processing of the file to be synchronized by the synchronizing terminal can be directly determined to be completed. Therefore, the file state of the file to be synchronized can be determined directly by judging whether the change type is deletion. And when the change type of the file to be synchronized is determined to be deleted, determining the file state of the file to be synchronized as a state representing that the processing of the file to be synchronized is completed.
When the change type of the file to be synchronized is determined to be new or modified, at this time, the synchronization end needs to copy the file to be added or modified, and the copying takes different time according to the performance of the equipment at the synchronization end and the size of the file, and the different files may finish copying under a preset period, and may have files which are not copied yet. Therefore, in this embodiment, when determining that the change type of the file to be synchronized is new or modified, the file state of the file to be synchronized cannot be directly obtained, and the file state may be determined by the file size of the file to be synchronized (i.e., the data size of the file to be synchronized).
In one embodiment, the process of determining the file status according to the change type and the data amount of the file to be synchronized includes: when the change type of the file to be synchronized is determined to be newly added or modified, determining the data volume of the file to be synchronized; and when the data quantity of the file to be synchronized is smaller than the preset data threshold value, determining the file state of the file to be synchronized as a state representing that the processing of the file to be synchronized is completed.
Different files to be synchronized may have different data volumes, for example, a part of the files may have smaller data volumes, the synchronization end may process in a short time, a part of the files may have larger data volumes, and the synchronization end may need to consume more time to copy.
In this embodiment, a data threshold may be preset, that is, a preset data threshold, and the synchronization end may be represented by the preset data threshold and may process the data amount in a preset period. And then, acquiring the data quantity of the file to be synchronized, comparing the data quantity of the file to be synchronized with a preset data threshold, and when the data quantity of the file to be synchronized is smaller than the preset data threshold, the characterization synchronization terminal can finish copying the file to be synchronized, and can send the file to be synchronized to the receiving terminal after finishing scanning in a preset period. For example, a file with a size of 1KB can be copied in a short time by the synchronous terminal, and then the file can be copied in a preset period and sent to the receiving terminal after the file is copied. Therefore, when the data volume of the file to be synchronized is smaller than the preset data threshold, determining the file state of the file to be synchronized as a state representing that the processing of the file to be synchronized is completed.
The data volume of the files to be synchronized can be obtained by scanning the files under the monitoring directory. The preset data threshold may be set reasonably according to the device performance of the synchronization end, and for example, the preset data threshold may be set to 20MB, 30MB, etc. if the device processing performance of the synchronization end is better, and may be set to 5MB, 10MB, etc. if the device processing performance of the synchronization end is worse. The foregoing is by way of example only and should not be construed as limiting the application.
When the data quantity of the file to be synchronized is larger than a preset data threshold value, the characterization synchronization terminal cannot copy the file to be synchronized completely in one scanning period, and at this time, the file state of the file to be synchronized can be determined to be a state representing that the file to be synchronized does not finish processing in the current scanning period.
In an embodiment, when it is determined that the data amount of the file to be synchronized is greater than a preset data threshold, a time variation attribute of the file to be synchronized may be obtained, where the time variation attribute includes a discovery time of the file to be synchronized and a modification time of the file to be synchronized; then, comparing the time difference between the discovery time and the modification time with a preset temporary storage duration; and finally, when the time difference is determined to be larger than the preset temporary storage time, determining that the file state to be synchronized is the state that the file processing to be synchronized is completed.
In this embodiment, the time variation attribute may include a discovery time of a file to be synchronized and a modification time of the file to be synchronized. The modification time of the file to be synchronized is recorded by the synchronization end after the file is modified, and the modification time can be checked and obtained in the attribute of the file to be synchronized. The discovery time of the file to be synchronized refers to the time of discovering the changed file in the monitoring directory when the monitoring directory is scanned.
It can be understood that when the data amount of the file to be synchronized is greater than the preset data threshold, at this time, the file to be synchronized cannot be copied within one scanning period, and synchronization can be performed after the file to be synchronized is copied, in this embodiment, a preset temporary storage time period can be set, and the synchronization end waits for the copying of the file to be synchronized to be completed by using the preset temporary storage time period.
In an embodiment, the number of files to be synchronized is multiple, and the preset temporary time period may be determined based on a hardware configuration of a device in which the files to be synchronized are located, and/or a proportion of the files to be synchronized with a data volume greater than a preset data threshold to all the files to be synchronized.
In this embodiment, the synchronization end is the device where the file to be synchronized is located, and when the device performance of the synchronization end is better, the synchronization end has higher copying efficiency of the file to be synchronized, and at this time, a shorter preset temporary time period can be set. For example, the performance of the apparatus 1 is superior to that of the apparatus 2, and when the preset temporary period of the apparatus 2 is set to 10 seconds, the preset temporary period of the apparatus 1 may be set to 8 seconds, 5 seconds, or the like.
In this embodiment, there may be multiple files under the monitoring directory, and at the same time, there may be different files that all change, i.e., any file may be a file to be synchronized, and different files have different sizes. The equipment performance of the synchronous end is limited, when a plurality of files with the data quantity larger than the preset data threshold value need to be copied, the copying of different files can be mutually influenced, so that when the proportion of the files to be synchronized with the data quantity larger than the preset data threshold value to all the files to be synchronized is larger, the preset temporary storage time can be appropriately increased, and otherwise, when the proportion is smaller, the preset temporary storage time can be appropriately reduced.
It can be understood that the preset temporary storage duration can be determined independently according to the hardware configuration of the device in which the file to be synchronized is located and the proportion of the file to be synchronized with the data volume greater than the preset data threshold to all the files to be synchronized, or can be determined together, which is only an example and should not be a limitation of the application.
The time difference obtained by subtracting the modification time from the found time is the time elapsed after the modification of the file to be synchronized, namely the time of copying before synchronization, and when the time difference is greater than the preset temporary storage time, the file to be synchronized is represented as being copied for a longer time, and the file to be synchronized can be regarded as being copied, so that the file state of the file to be synchronized can be determined as the file state representing the completion of processing of the file to be synchronized.
S130, synchronizing the file to be synchronized with the receiving end when determining that the file state represents that the file to be synchronized is processed.
By the method, the file state of the file to be synchronized can be determined, when the file state is determined to represent that the processing of the file to be synchronized is completed, the file to be synchronized is represented as being completely copied, and the file to be synchronized can be sent to a receiving end for storage at the moment, so that the synchronization of the files at the synchronizing end and the receiving end is realized.
For the file to be synchronized with the change type deleted, after the change type is determined, a deletion instruction can be sent to the receiving end, and the deletion instruction is used for indicating the receiving end to delete the file to be synchronized, so that synchronization of the file at the synchronizing end and the file at the receiving end is realized.
In the embodiment of the application, the file to be synchronized is determined first, the state of the file to be synchronized is determined, and when the file state characterizes that the processing of the file to be synchronized is completed, the file to be synchronized is synchronized with the receiving end, so that the transmission of the file which is not processed to the receiving end can be reduced, and the accuracy and the integrity of file transmission are improved. Meanwhile, the transmission of the files which are not processed is reduced, so that the repeated transmission of the files after the processing is completed can be reduced, and the occupation of the bandwidth caused by the repeated transmission of the files to be synchronized is reduced.
Based on the same inventive concept, the embodiment of the application also provides a file synchronization device. Referring to fig. 3, fig. 3 is a schematic diagram of a file synchronization device according to an embodiment of the present application, where the file synchronization device 200 includes: the scanning module 210 is configured to scan the image, a status module 220 and a synchronization module 230.
The scanning module 210 is configured to determine a file to be synchronized, where the file to be synchronized is a file that changes under the monitoring directory.
The status module 220 is configured to determine a file status of the file to be synchronized based on a change attribute of the file to be synchronized, where the change attribute is used to characterize a change condition of the file to be synchronized.
And the synchronization module 230 is configured to synchronize the file to be synchronized with the receiving end when determining that the file status indicates that the processing of the file to be synchronized is completed.
The scanning module 210 is further configured to scan the file under the monitoring directory based on a preset period; and when the files under the monitoring directory are determined to change in two adjacent periods, determining the changed files as files to be synchronized.
The status module 220 is further configured to determine a change type of the file to be synchronized, where the change type includes adding, deleting, and modifying; and determining the file state of the file to be synchronized based on the preset relation between the change type and the file state and the change type of the file to be synchronized.
The status module 220 is further configured to determine, when the change type of the file to be synchronized is deletion, that the file status of the file to be synchronized is a status indicating that the processing of the file to be synchronized is completed. The synchronization module 230 is further configured to send a delete instruction to the receiving end, the deleting instruction is used for indicating the receiving end to delete the file to be synchronized.
The status module 220 is further configured to determine a data amount of the file to be synchronized when determining that the change type of the file to be synchronized is new or modified; and when the data quantity of the file to be synchronized is smaller than the preset data threshold value, determining the file state of the file to be synchronized as a state representing that the processing of the file to be synchronized is completed.
The state module 220 is further configured to obtain a time variation attribute of the file to be synchronized when it is determined that the data amount of the file to be synchronized is greater than a preset data threshold, where the time variation attribute includes a discovery time of the file to be synchronized and a modification time of the file to be synchronized, compare a time difference between the discovery time and the modification time with a preset temporary storage duration, and determine that the state of the file to be synchronized is a state representing that the processing of the file to be synchronized is completed when it is determined that the time difference is greater than the preset temporary storage duration.
The status module 220 is further configured to determine a preset temporary duration based on a hardware configuration of a device in which the file to be synchronized is located, and/or a proportion of the file to be synchronized with a data amount greater than a preset data threshold to all the files to be synchronized.
It can be understood that the file synchronization device corresponds to the file synchronization method, and specific implementation contents may refer to the file synchronization method, which is not described herein. The above-described file synchronization apparatus and method may be embodied in the form of computer readable instructions that may be executed on an electronic device as shown in fig. 4.
Referring to fig. 4, an embodiment of the present application further provides an electronic device 300, which may be used as an execution body of the file synchronization method, including: a processor 310 and a memory 320 communicatively coupled to the processor 310.
Wherein the memory 320 stores instructions executable by the processor 310, the instructions being executable by the processor 310, to enable the processor 310 to perform the file synchronization method of the previous embodiments.
The processor 310 and the memory 320 may be connected by a communication bus. Or by some communication module, such as: wireless communication module, bluetooth communication module, 4G/5G communication module, etc.
The processor 310 may be an integrated circuit chip with signal processing capabilities. The processor 310 may be a general-purpose processor including a CPU (Central Processing Unit ), NP (Network Processor, network processor), etc.; but may be a digital signal processor, an application specific integrated circuit, an off-the-shelf programmable gate array or other programmable logic device or transistor logic device, discrete hardware components. Which may implement or perform the disclosed methods, steps, and logic blocks in embodiments of the present application. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Memory 320 may include, but is not limited to, RAM (Random Access Memory ), ROM (Read Only Memory), PROM (Programmable Read-Only Memory, programmable Read Only Memory), EPROM (Erasable Programmable Read-Only Memory, erasable programmable Read Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory, electrically erasable programmable Read Only Memory), and the like.
It will be appreciated that the electronic device 300 may also include more general modules as needed by itself, and embodiments of the present application are not described in detail.
Based on the same inventive concept, the present embodiments also provide a computer-readable storage medium having stored thereon a computer program which, when executed, performs the method provided in the above embodiments.
The storage media may be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., a floppy Disk, a hard Disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., an SSD (Solid State Disk)), or the like.
In the embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other manners as well. The device embodiments described above are merely illustrative. The functional modules in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk, an optical disk, or other various media capable of storing program codes.
The foregoing is merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A method for synchronizing files, comprising:
determining a file to be synchronized, wherein the file to be synchronized is a file which changes under a monitoring directory;
determining a file state of the file to be synchronized based on a change attribute of the file to be synchronized, wherein the change attribute is used for representing the change condition of the file to be synchronized;
and synchronizing the file to be synchronized with a receiving end when determining that the file state characterizes the completion of the file processing to be synchronized.
2. The method of claim 1, wherein the determining the file to be synchronized comprises:
scanning the files under the monitoring directory based on a preset period;
and when the files under the monitoring directory are determined to be changed in two adjacent periods, determining the changed files as the files to be synchronized.
3. The method of claim 2, wherein the change attribute comprises a change type, and wherein the determining the file state of the file to be synchronized based on the change attribute of the file to be synchronized comprises:
determining the change type of the file to be synchronized, wherein the change type comprises addition, deletion and modification;
and determining the file state of the file to be synchronized based on the preset relation between the change type and the file state and the change type of the file to be synchronized.
4. A method according to claim 3, wherein said determining the file status of the file to be synchronized based on the preset relationship between the change type and the file status, the change type of the file to be synchronized, comprises: when the change type of the file to be synchronized is determined to be deleted, determining the file state of the file to be synchronized as a state representing that the processing of the file to be synchronized is completed;
correspondingly, the synchronizing the file to be synchronized with the receiving end includes: and sending a deleting instruction to the receiving end, wherein the deleting instruction is used for indicating the receiving end to delete the file to be synchronized.
5. The method of claim 3, wherein determining the file status of the file to be synchronized based on the preset relationship between the type of change and the file status, the type of change of the file to be synchronized includes determining 5 the amount of data of the file to be synchronized when the type of change of the file to be synchronized is determined to be newly added or modified;
and when the data quantity of the file to be synchronized is smaller than a preset data threshold value, determining the file state of the file to be synchronized as a state representing that the processing of the file to be synchronized is completed.
6. The method of any of claims 1-5, wherein the change attribute comprises a time change attribute, and wherein determining the file state of the file to be synchronized 0 based on the change attribute of the file to be synchronized comprises:
when the data volume of the file to be synchronized is determined to be larger than a preset data threshold, acquiring the time change attribute of the file to be synchronized, wherein the time change attribute comprises the discovery time of the file to be synchronized 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 time length by 5;
and when the time difference is determined to be larger than the preset temporary storage time length, determining the file state to be synchronized as a state representing that the file processing to be synchronized is completed.
7. The method of claim 6, wherein the file to be synchronized is a plurality of files,
before comparing the time difference between the discovery time and the modification time with a preset temporary storage duration by 0, the method further comprises:
and determining the preset temporary storage duration based on the hardware configuration of the equipment where the files to be synchronized are located and/or the proportion of the files to be synchronized with the data volume larger than a preset data threshold value to all the files to be synchronized.
8. A file synchronization system, comprising:
a synchronization end, configured to perform the file synchronization method according to any one of claims 1 to 7;
the receiving end is in communication connection with the synchronizing end and is used for synchronizing the file to be synchronized with the synchronizing end.
9. An electronic device comprising a memory and a processor, the memory having stored therein computer readable instructions that, when executed by the processor, cause the processor to perform the method of any of claims 1-7.
10. A computer readable storage medium, characterized in that the computer program is stored in the readable storage medium, which, when run on a computer, causes the computer to perform the method according to any one of claims 1-7.
CN202211731966.3A 2022-12-30 2022-12-30 File synchronization method, system, electronic equipment and storage medium Pending CN116319826A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211731966.3A CN116319826A (en) 2022-12-30 2022-12-30 File synchronization method, system, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211731966.3A CN116319826A (en) 2022-12-30 2022-12-30 File synchronization method, system, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116319826A true CN116319826A (en) 2023-06-23

Family

ID=86784076

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211731966.3A Pending CN116319826A (en) 2022-12-30 2022-12-30 File synchronization method, system, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116319826A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116527691A (en) * 2023-06-27 2023-08-01 天津中远海运散运数字科技有限公司 Method, device, equipment and medium for synchronizing ship-shore data

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116527691A (en) * 2023-06-27 2023-08-01 天津中远海运散运数字科技有限公司 Method, device, equipment and medium for synchronizing ship-shore data
CN116527691B (en) * 2023-06-27 2023-11-03 天津中远海运散运数字科技有限公司 Method, device, equipment and medium for synchronizing ship-shore data

Similar Documents

Publication Publication Date Title
CN109739810B (en) File synchronization method, server, client and device with storage function
EP2369501A2 (en) Information processing apparatus, information processing method, data management server and data synchronization system
EP3125501A1 (en) File synchronization method, server, and terminal
CN103457973A (en) Image uploading method and system, image uploading client terminal and network server
EP3163946A1 (en) Information transmission method and apparatus, device, computer program and recording medium
CN116319826A (en) File synchronization method, system, electronic equipment and storage medium
CN116170870B (en) Network registration method and device, storage medium and electronic equipment
CN110830823A (en) Play progress correction method and device, electronic equipment and readable storage medium
CN111291252B (en) Method and device for adjusting query rate per second, electronic equipment and storage medium
CN110888844A (en) Data deleting method, system, equipment and computer readable storage medium
CN111158947A (en) Method for making pre-copy file, server and readable storage medium
CN111181791A (en) Quota management method, device, equipment and storage medium
CN110308938B (en) Management method and device for plugging and unplugging peripheral events
TWI795551B (en) Exclusive control system and exclusive control method
CN109324760B (en) Disk data cloud method, system, equipment and computer storage medium
CN113746932A (en) Network request merging method and device, electronic device and computer program product
CN111104381A (en) Log management method, device and equipment and computer readable storage medium
US20160277628A1 (en) Information processing apparatus, information processsing system, and non-transitory computer readable medium
WO2020049746A1 (en) Database device, program, and data processing method
CN111464395A (en) Method and device for creating block chain and readable storage medium
CN108052648B (en) Website picture deleting method and device and electronic equipment
CN113852919B (en) Method and device for generating early warning message, storage medium and electronic device
CN115442226B (en) Log acquisition method, related device and storage medium
WO2022042514A1 (en) Metadata synchronization method and apparatus
CN112925745B (en) Data cleaning method and device, electronic equipment and computer readable 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