A method, comparison device, and storage medium for file comparison and synchronization.
By establishing a connection upon receiving information on the comparison device, obtaining and comparing server files and marking differences, and automatically updating reference files, the problem of inconsistent file configurations in the test environment is solved, achieving efficient file synchronization and configuration management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-12
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies struggle to efficiently compare files and synchronize configurations between different servers in a test environment, especially when modifying configuration files on multiple servers, which can easily lead to inconsistencies. Furthermore, existing methods require high-privilege operations or container refactoring, making them difficult to use.
This invention provides a method and device for file comparison and synchronization. It establishes a connection by receiving login information and target server information, obtains reference files and target files for comparison, marks difference codes, and automatically updates reference files. It supports batch file comparison and synchronization and uses a Git database for file management.
It enables simple and efficient file comparison and synchronization between different servers, reduces high-privilege operations and reconstruction workload, improves user experience and comparison efficiency, and ensures consistency of file configuration.
Smart Images

Figure CN116775572B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of document comparison technology, and in particular to a method, comparison device and storage medium for document comparison synchronization. Background Technology
[0002] As we all know, the backends of the apps we use or the web applications we access are deployed on application servers. As the number of users increases, so does the number of servers. Checking or maintaining configuration files on a large number of servers becomes extremely difficult. This is especially true in test environments, where it's necessary to check and modify configuration files for test scenarios. Sometimes, changes are made but then forgotten to revert to the original code on the server, or inconsistencies arise between configurations on multiple application servers. Ultimately, ensuring configuration consistency becomes a major challenge, and the more environments and configuration files involved, the harder it is to check.
[0003] The two existing methods for file comparison and synchronization are difficult to implement in test environments. There is an urgent need for a simple and efficient method to perform file comparison, configuration synchronization and other functions between different servers. Summary of the Invention
[0004] This application provides a method for file comparison and synchronization to solve the aforementioned technical problems. The method is applied to a comparison device connected to at least one server, and the method includes:
[0005] The first information is received, which includes login information, target server information, and target file information.
[0006] Based on the login information and the target server information, the target server is located from the at least one server, and a connection is established with the target server;
[0007] Based on the target file information, obtain the reference file and the target file from the target server;
[0008] The reference file is synchronized with the target file to update the reference file.
[0009] The target server includes a first server and a second server; the target file information includes first target file information and second target file information.
[0010] The step of obtaining the target file from the target server based on the target file information includes:
[0011] The reference file is obtained from the first server based on the first target file information;
[0012] The target file is obtained from the second server based on the second target file information.
[0013] The step of synchronizing the reference file with the target file includes:
[0014] The reference file and the target file are compared, and modification codes are marked on the reference file, wherein the modification codes are the codes in the reference file that differ from the target file;
[0015] Based on the modified code, the reference file is modified to obtain an updated file.
[0016] The step of updating the reference file to the target file includes:
[0017] The updated file is transmitted to the first server, and the updated file replaces the reference file in the first server.
[0018] The comparison device includes a display interface, and the step of synchronizing the reference file with the target file further includes:
[0019] The reference file and the target file are displayed side by side on the display interface, and the reference file is marked according to the modified code.
[0020] The step of synchronizing the reference file with the target file further includes:
[0021] A pre-stored comparison table is provided, wherein the comparison table includes information on multiple target files;
[0022] Iterate through the information of multiple target files in the comparison table;
[0023] Based on the first target file information and the second target file information, the reference file and the target file are obtained cyclically and compared to obtain multiple modified codes.
[0024] Multiple updated files were obtained based on the aforementioned modified code.
[0025] The target server includes a first server and a Git database, the first information further includes Git interface information, and the method further includes:
[0026] Based on the target file information, the reference file is obtained from the first server;
[0027] Based on the Git interface information, a connection is established with the Git database and the target file is obtained from the Git database.
[0028] The Git database is a collection of code files in the test environment.
[0029] To address the aforementioned technical problems, this application also provides a file comparison and synchronization device, the comparison device comprising a memory and a processor, the memory storing program instructions, and the processor executing the program instructions to implement the method described above.
[0030] To address the aforementioned technical problems, this application also provides a computer-readable storage medium storing program instructions that are executed by a processor to implement the method described above.
[0031] The beneficial effects of this application are as follows: Unlike existing technologies, the file comparison and synchronization method of this application is applied to a comparison device. Upon receiving the first information, the comparison device locates at least one target server and establishes a connection with it. Based on the target file information, it retrieves the reference file and the target file from the target server, synchronizes the reference file and the target file, and thus updates the reference file. Through this method, only login authentication to the target server and retrieval of the file from the target server are required. This allows for simple and efficient file retrieval and comparison, thereby updating the reference file. It avoids the complex operations required by high-level server permissions, high usage difficulty, or the need to repeatedly build file libraries to ensure synchronized file updates. Attached Figure Description
[0032] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0033] Figure 1 This is a flowchart illustrating the first embodiment of the method provided in this application;
[0034] Figure 2 This is a flowchart illustrating the second embodiment of the method provided in this application;
[0035] Figure 3 This is a flowchart illustrating the third embodiment of the method provided in this application;
[0036] Figure 4 This is a flowchart illustrating the fourth embodiment of the method provided in this application;
[0037] Figure 5 This is a schematic diagram of the structure of the first embodiment of the comparative device provided in this application;
[0038] Figure 6 This is a schematic diagram of the structure of the first embodiment of the computer-readable storage medium of this application.
[0039] Reference numerals: 5 for comparison device; 51 for memory; 52 for processor; 6 for computer-readable storage medium; 61 for program instructions. Detailed Implementation
[0040] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0041] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0042] The document comparison and synchronization method provided in this application is mainly applied to a comparison device, which can be a server or a system consisting of a server and terminal devices working together. Accordingly, the various parts of the comparison device, such as units, subunits, modules, and submodules, can be all located in the server, or they can be located separately in the server and terminal devices.
[0043] Furthermore, the aforementioned server can be either hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the server is software, it can be implemented as multiple software programs or software modules, such as software or software modules used to provide distributed servers, or as a single software program or software module; no specific limitation is made here. In some possible implementations, the file comparison and synchronization method of this application embodiment can be implemented by the processor calling program instructions stored in memory.
[0044] The file comparison and synchronization method provided in this application is mainly applied to the configuration of file synchronization between servers. For example, in a test environment, it is often necessary to modify the configuration of code files to test certain scenarios. If the test fails after modification, the code file needs to be reverted to the original version; or if the test succeeds after modification, the code file needs to be synchronized to other servers. However, replacing all files on the server would be a large workload. Therefore, by comparing the changed files, marking the differences, and then modifying the differences, file synchronization can be achieved.
[0045] Currently, file comparison and synchronization primarily employs two methods. One method is containerized deployment, where each deployment uses a completely new container, eliminating concerns about inconsistent configuration files. However, containerization requires the reconstruction of the servers involved in the comparison and synchronization, which is time-consuming and labor-intensive, making it impractical for real-world applications. The other method utilizes an operations and maintenance tool called Ansible. Ansible can perform file checks and modifications by executing Linux commands. However, using Ansible requires high-level server privileges, is difficult to use, lacks file comparison functionality, and is limited in its widespread adoption.
[0046] Based on this, this application provides a method for file comparison and synchronization. The technical solution adopted in this application is described in detail below. Please refer to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the method provided in this application. The comparison and synchronization method described in this application is applied to a comparison device, which is connected to at least one server. Specific steps include:
[0047] S11: First message received.
[0048] Before file comparison and synchronization begins, the user sends initial information to the comparison device. Upon receiving this initial information, the comparison device immediately begins acquiring files and performing file comparison and synchronization. This initial information includes login information, target server information, and target file information.
[0049] Login information, also known as login credentials, is used to access servers that the user has permission to access. Based on this login information, the comparison device establishes a connection with at least one authorized server. The target server is included among the authorized servers connected to the comparison device. Information about the target server is used to further filter servers to obtain the server that provides the user with the files. The target file information corresponds to the files used for comparison and synchronization. Based on this target file information, the comparison device can obtain the reference file and the target file from the target server. The target file is used to compare with the reference file, and the reference file is updated based on the differences between the two files.
[0050] S12: Based on the login information and the target server information, locate the target server from at least one server and establish a connection with the target server.
[0051] The comparison device finds at least one server that the user has permission to access based on the login information in the first information; the target server information provides the comparison device with a path to find the target server; based on the target server information, the comparison device finds the target server from at least one server, including the server that provides the reference file and the server that provides the target file.
[0052] In one embodiment, the server providing the target file can be a server in a test environment. Users modify and test the file on the server. If the test passes, it means that the file can function, and the file is then set as the target file. The server providing the reference file is a server that needs to modify and improve the reference file multiple times. Synchronizing the code in the target file to the reference file can help improve both the reference file and the server.
[0053] In another embodiment, the server providing the reference file can be a server in a test environment. Users modify the file on the server and test it. If the test fails, it indicates that the file has not functioned as intended, and the modified file needs to be restored to prepare for the next modification. The code content in the target file is identical to the code content in the unmodified reference file. Therefore, synchronizing the reference file with the comparison file means removing the modifications to the reference file, preparing for the next modification of the reference file.
[0054] S13: Obtain the reference file and target file from the target server based on the target file information.
[0055] The target file information provides the comparison device with the path to find the reference file and the target file. Based on the target file information, the comparison device obtains the reference file and the comparison file from the target server, respectively.
[0056] S14: Synchronize the reference file and the target file.
[0057] The comparison device compares and synchronizes the obtained reference file and target file. That is, it modifies the code in the reference file that is different from the target file so that the code content in the reference file is the same as the code content in the target file, thus completing the update of the reference file and updating the server that provides the reference file.
[0058] Using the above method, the comparison device obtains the reference file and the target file from the target server, compares and synchronizes the reference file with the target file, thereby automatically updating the reference file. This provides a simple and efficient method for comparing files and synchronizing configurations between different servers, improving the user experience.
[0059] Please see Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the method provided in this application. The target server may include a first server and a second server. The first server is a server providing a reference file, and the second server is a server providing the target file. The target file information includes first file information and second file information. The specific steps for obtaining the target file from the target server based on the target file information and synchronizing the reference file with the target file include:
[0060] S21: Obtain a reference file from the first server based on the first target file information; obtain a target file from the second server based on the second target file information.
[0061] The first target file information corresponds to the acquisition path of the reference file in the first server, and the second target file information corresponds to the acquisition path of the target file in the second server. Therefore, the comparison device can acquire the reference file from the first server based on the first target file information and acquire the target file from the second server based on the second target file information.
[0062] S22: Compare the reference file with the target file and mark the modified code on the reference file.
[0063] In this embodiment, the comparison device may include a display interface. After obtaining the reference file and the target file in step S21, the comparison device displays the reference file and the target file side by side on the display interface for easy viewing by the user. The comparison device compares the side-by-side reference file and target file and marks the reference file based on the modified code. The modified code refers to the code in the reference file that differs from the target file; marking the modified code on the reference file can involve changing the background color of the modified code, or changing the font color or font size, etc. This application does not limit how the marking is done. Marking the modified code on the reference file allows the user to quickly locate the modified code, improving comparison efficiency.
[0064] S23: Modify the reference file based on the modified code to obtain the updated file.
[0065] Based on the modification codes marked on the reference file, in one embodiment, the user can decide on the display interface whether to modify a certain mark to obtain an updated file. In another embodiment, the comparison device can also accept all the code and directly modify the marked modification codes in the reference file to be identical to the code in the target file, thereby obtaining an updated file.
[0066] S24: Transfer the updated file to the first server and replace the reference file.
[0067] In this embodiment, the comparison device obtains a reference file from the first server based on the first target file information. Specifically, the comparison device copies the reference file from the first server. That is, the file displayed on the display interface is a copy of the reference file. After the copy of the reference file and the target file are synchronized to obtain an updated file, the comparison device transmits the updated file to the location of the reference file in the first server based on the first target file information, and replaces the reference file in the first server with the updated file, thereby updating the reference file.
[0068] In other embodiments, the comparison device may also directly extract the reference file from the first server, where the original location where the reference file was stored in the first server is vacant. After the comparison device obtains the updated file, it sends the updated file back to the vacant location, thereby updating the reference file.
[0069] In summary, the comparison device retrieves a reference file from the first server and a target file from the second server. It then compares the reference and target files on the display interface, marking any modified code for easy viewing by the user. Based on the modified code, the reference file is modified to synchronize the configurations of the reference and target files, resulting in an updated file. The comparison device then returns the updated file to replace the reference file on the first server, thus completing the update of the reference file on the first server. The entire process can be automated by the comparison device, improving the user experience.
[0070] In practical applications, the file comparison and synchronization method provided in this application is also applicable to the comparison and synchronization of batch files. Please refer to [link / reference]. Figure 3 , Figure 3 This is a flowchart illustrating the third embodiment of the method provided in this application. The comparison device is applied to the comparison and synchronization of batch files, specifically including the following steps:
[0071] S31: Pre-stored comparison table.
[0072] If the comparison device needs to compare and synchronize a batch of files, the user must first pre-store a comparison table in the comparison device. This comparison table contains login information, target server information, and information about multiple target files corresponding to the target server. The comparison device establishes connections with the first and second servers based on the login and target server information. The multiple target file information corresponds to multiple reference files and multiple target files on the first and second servers.
[0073] S32: Iterate through and compare information from multiple target files in the table.
[0074] The comparison device iterates through multiple target file information in the comparison table and obtains a batch of reference files and target files from the target server based on the target file information.
[0075] S33: Based on the information of the first target file and the information of the second target file, repeatedly obtain the reference file and the target file and compare them to obtain multiple modified codes.
[0076] In this embodiment, the comparison device obtains a reference file from the first server and a target file from the second server based on the first target file information and the second target file information, and displays the reference file and target file on the display interface, marking the modified code on the reference file. Simultaneously, based on another set of target file information in the comparison table, the comparison device obtains another set of reference files and target files from the first server and the second server, repeatedly obtaining multiple reference files and target files, comparing them on the display interface, and marking the modified code obtained from each set of file comparisons.
[0077] S34: Obtain multiple updated files based on multiple modified code.
[0078] In step S33, after the modification codes are marked on the display interface of the reference file and the target file, the user can decide whether to modify a certain code. After the user has modified all the marked modification codes in the reference file, the modified reference file is stored as an updated file. At the same time, the comparison device displays another set of reference files and target files on the display interface, and marks another type of modification code. The user then modifies these codes and generates another set of updated files. This process is repeated until a batch of reference files and target files in the comparison table are compared, generating multiple updated files.
[0079] In other embodiments, the comparison device can also directly extract multiple reference files and target files at once based on the target file information in the comparison table, compare them, automatically modify the reference files based on the modified code, and obtain multiple updated files at the same time, reducing user operations.
[0080] Through the above embodiments, the comparison device can be applied to the comparison and synchronization of batch reference files. This provides users with an efficient and convenient method for batch comparison of server files in a test environment, saving users' waiting time for file comparison, improving the efficiency of file comparison, and enhancing the user's experience of using this method.
[0081] For updates to reference files in the production environment, it's necessary to compare them with target files implementing the functionality of the reference file in the test environment. The target files in the test environment have been proven effective in numerous practical applications. Comparing the reference files with these proven target files better facilitates updates to the reference files and ensures consistency between the content in production and the content on the test environment server. Figure 4 As shown, Figure 4 This is a flowchart illustrating the fourth embodiment of the method provided in this application. The steps for verifying the content before production include:
[0082] S41: Establish a connection with the first server and the Git database.
[0083] When verifying the content to be deployed in production, the first information sent by the user to the comparison device also includes Git interface information. The comparison device can then locate the first server and establish a connection based on the target server information, and locate the Git database and establish a connection based on the Git interface information. The first server is the server that will be deployed in production, and the Git database is the collection of code files implementing the functionality in the test environment.
[0084] S42: Retrieve the reference files from the first server and the target files from the Git database.
[0085] Once the comparison device establishes a connection with the first server and the Git database, it retrieves the target file and reference file from the Git database and the first server based on the target file information and Git interface information.
[0086] S43: Compare the reference file and the target file to obtain the updated file.
[0087] The comparison device compares the acquired reference file and target file to obtain the updated file. When comparing a single reference file and a single target file, the second server in steps S21-S24 is replaced with a Git database; other operation procedures remain the same and will not be described in detail here. When comparing a batch of reference files and target files, the second server in steps S31-S34 is replaced with a Git database; other operation procedures remain the same and will not be described in detail here.
[0088] The above method enables the verification of content on the first server before production deployment, avoiding inconsistencies between code content in the test environment and the production environment. Furthermore, it automatically compares and updates files on the first server with the Git database, reducing user operations, improving comparison efficiency, and enhancing the user experience.
[0089] In summary, this method is suitable for comparing and updating files between different servers, and can automatically synchronize file configurations, reducing user operations during the synchronization process; it can perform batch operations on files, improving the efficiency of file comparison and enhancing the user experience of file comparison and synchronization methods.
[0090] Unlike existing technologies, the file comparison and synchronization method of this application is applied to a comparison device. Upon receiving the first information, the comparison device locates at least one target server and establishes a connection with it. Based on the target file information, it retrieves the reference file and the target file from the target server, displays them on the comparison device's interface, and marks the modified code so that the user can quickly locate the modified code and decide whether to modify it. After modifying the reference file according to the modified code, an updated file is obtained. The comparison device then transmits the updated file back to the target server, updating the reference file on the target server and synchronizing its configuration with the target file. This method ensures synchronized configuration between files by updating the reference file on the target server. Furthermore, the comparison device can establish a connection with the target server using login information and target server information, and directly retrieve the reference file and the target file from the target server using the target file information. This avoids the complex operations required by servers with high privileges, high access difficulty, or the need to repeatedly build file libraries to ensure synchronized file updates.
[0091] This application also provides a file comparison and synchronization device; please refer to [link / reference]. Figure 5 , Figure 5 This is a schematic diagram of the structure of the first embodiment of the comparative device of this application. The comparative device 5 provided in this application includes a memory 51 and a processor 52. The memory 51 stores program instructions (not shown), and the processor 52 executes the program instructions to implement the method described above.
[0092] In this embodiment, processor 52 may also be referred to as a CPU (Central Processing Unit). Processor 52 may be an integrated circuit chip with signal processing capabilities; it may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. Processor 52 may be a microprocessor or any conventional processor.
[0093] The following is the workflow of one embodiment of comparative device 5:
[0094] The user sends the first information to the comparison device 5 through its display interface. Upon receiving the first information, the comparison device 5 locates the first server and the second server from at least one authorized server and establishes connections with them. After establishing the connection, the comparison device 5 retrieves the reference file from the first server and the target file from the second server based on the target file information, and displays the retrieved reference file and target file side-by-side on the display interface. Based on the modified code, the comparison device 5 marks the reference file. The user decides whether to modify a certain part of the modified code based on the mark, thereby obtaining an updated file. The comparison device 5 then transmits the updated file to the location of the reference file on the first server according to the target file information, replacing the original reference file on the first server, thus achieving synchronized updates of the reference file.
[0095] This application also provides a computer-readable storage medium; please refer to [link / reference]. Figure 6 , Figure 6 This is a schematic diagram of the structure of a first embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 6 provided in this application stores program instructions 61, which are executed by processor 52 to implement the method described above.
[0096] When embodiments of this application are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium 6. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium 6 and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned computer-readable storage medium 6 includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0097] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for file comparison and synchronization, characterized in that, Applied to a comparison device connected to at least one server, the method includes: The first information is received, which includes login information, target server information, and target file information. Based on the login information and the target server information, the target server is located from the at least one server, and a connection is established with the target server; Based on the target file information, obtain the reference file and the target file from the target server; The reference file is synchronized with the target file to update the reference file; The step of synchronizing the reference file with the target file includes: The reference file and the target file are compared, and modification codes are marked on the reference file, wherein the modification codes are the codes in the reference file that differ from the target file; Based on the modified code, the reference file is modified to obtain an updated file; The comparison device includes a display interface, and the step of synchronizing the reference file with the target file further includes: The reference file and the target file are displayed side by side on the display interface, and the reference file is marked according to the modified code.
2. The method according to claim 1, characterized in that, The target server includes a first server and a second server; the target file information includes first target file information and second target file information; The step of obtaining the target file from the target server based on the target file information includes: The reference file is obtained from the first server based on the first target file information; The target file is obtained from the second server based on the second target file information.
3. The method according to claim 2, characterized in that, The step of updating the reference file to the target file includes: The updated file is transmitted to the first server, and the updated file replaces the reference file in the first server.
4. The method according to claim 2, characterized in that, The step of synchronizing the reference file with the target file further includes: A pre-stored comparison table is provided, wherein the comparison table includes information on multiple target files; Iterate through the information of multiple target files in the comparison table; Based on the first target file information and the second target file information, the reference file and the target file are obtained cyclically and compared to obtain multiple modified codes; Multiple updated files were obtained based on the aforementioned modified code.
5. The method according to claim 1, characterized in that, The target server includes a first server and a Git database, the first information further includes Git interface information, and the method further includes: Based on the target file information, the reference file is obtained from the first server; Based on the Git interface information, a connection is established with the Git database and the target file is obtained from the Git database.
6. The method according to claim 5, characterized in that, The Git database is a collection of code files used in the test.
7. A file comparison and synchronization device, characterized in that, The comparison device includes a memory and a processor, the memory storing program instructions, and the processor executing the program instructions to implement the method as described in any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions that are executed by a processor to implement the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Server, client side and file synchronization method
CN104243508A