A directory version management method and device

By establishing the association relationship between directory files and version numbers in the IPFS system, and generating and adding hash values ​​to the version file name through hash operation, the problem of the inability to determine the version in file transfer is solved, and the accuracy and security of version verification are achieved.

CN114116657BActive Publication Date: 2025-08-22NSFOCUS INFORMATION TECHNOLOGY CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111316102.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-08
Publication Date
2025-08-22
Estimated Expiration
2041-11-08

AI Technical Summary

Technical Problem

During file transfer, the prior art cannot determine whether the transferred version is the required version, especially in IPFS systems. Although the content of the file is changed through CID, it is impossible to determine whether the version is correct.

Method used

Establish an association relationship between the directory file and the version number, generate a second hash value by hashing the directory file and add it to the file name of the version file to verify whether the version of the directory file is the same as the version indicated by the version number.

Benefits of technology

It can accurately determine whether the version of the directory file is correct during file transfer, improve the security and accuracy of version verification, and avoid the transmission of version errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114116657B_ABST
    Figure CN114116657B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for managing directory versions, which establishes a relationship between directory files and version numbers to solve the problem of being unable to determine the directory version during transmission. The method provided in the present application includes: performing a hash operation on multiple first sub-files to be sent to obtain a first hash value, and obtaining a first version file based on the first hash value; wherein, the multiple first sub-files and the first version file constitute a first directory file, and the first version file includes the first hash value and the first version number corresponding to the file group composed of the multiple first sub-files; performing a hash operation on the first directory file to obtain a second hash value, and adding the second hash value to a set position in the file name of the first version file; wherein, the second hash value is used to verify whether the version of the first directory file is the same as the version indicated by the version number in the first version file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method and device for managing directory versions. Background Art

[0002] When transmitting over a network, transferring between devices, copying large files, etc., there may be inconsistencies in the data transmitted before and after. Therefore, it is particularly important to verify the integrity of the file. The existing md5sum command that comes with Linux is used to generate and verify the md5 value of the file. It verifies the content of the file bit by bit and has nothing to do with the file name. Therefore, when the file name is changed, it is impossible to determine whether the file has been changed. After executing the existing ipfs add command, it can return the content identifier (Content Identifier, CID) of the file directory. The CID can uniquely identify the content of a file directory. However, in network transmission, when different versions of a file are transmitted, although the CID can be calculated to verify whether the file content has been changed, it is impossible to determine whether the transmitted version is the required version. Summary of the Invention

[0003] The embodiments of the present application provide a directory version management method and device, which establish a relationship between directory files and version numbers to solve the problem of being unable to determine the directory version during the transmission process.

[0004] In the first aspect, an embodiment of the present application provides a directory version management method, including: performing a hash operation on multiple first sub-files to be sent to obtain a first hash value, and obtaining a first version file based on the first hash value; wherein, the multiple first sub-files and the first version file constitute a first directory file, and the first version file includes the first hash value and the first version number corresponding to the file group composed of the multiple first sub-files; performing a hash operation on the first directory file to obtain a second hash value, and adding the second hash value to a set position in the file name of the first version file; wherein, the second hash value is used to verify whether the version of the first directory file is the same as the version indicated by the version number in the first version file.

[0005] Based on this solution, an association is established between the directory file and the version number. The receiving end can use the second hash value to verify whether the version of the first directory file is the same as the version indicated by the version number in the version file. Furthermore, during transmission, the hash value of the directory file need not be transmitted; the second hash value can be directly extracted from a specified location in the version file name, thereby improving the security of the second hash value used for version verification.

[0006] In a possible implementation, obtaining the first version file based on the first hash value includes: creating a second version file, and saving the first hash value and the first version number in the second version file to obtain the first version file.

[0007] Based on the above solution, when there is no version file in the directory file, a version file is created in the directory file to save the hash value and version number of the directory file.

[0008] In some other possible implementations, the method further includes: obtaining a second directory file, the second directory file including a third version file and the multiple first sub-files; obtaining the first version file based on the first hash value includes: adding the first hash value and the first version number to the third version file to obtain the first version file.

[0009] In another possible implementation, obtaining the second directory file includes: receiving a third directory file, the third directory file including the multiple second sub-files and a fourth version file; the fourth version file including the second version numbers of the multiple second sub-files and a first check value for verifying whether the versions of the multiple second sub-files are the same as the version indicated by the second version number; extracting the second check value from the set position of the file name of the fourth version file; deleting the second check value in the file name of the fourth version file in the third directory file to obtain a fourth directory file; performing a hash operation on the fourth directory file to obtain a third hash value; when it is determined that the second check value is the same as the third hash value, performing a hash operation on the multiple second sub-files in the fourth directory file to obtain a fourth hash value; when it is determined that the first check value is the same as the fourth hash value, verifying that the version of the third directory file is the same as the version indicated by the second version number; and changing the content of at least one sub-file among the multiple second sub-files to obtain the multiple first sub-files, so as to obtain the second directory file.

[0010] Based on the above solution, before receiving and modifying the directory file, a version check is performed. When it is determined that the received version is consistent with the sent version, the modification is performed, thereby ensuring the correctness of the directory file during subsequent transmission.

[0011] In a second aspect, an embodiment of the present application provides a directory version verification method, applied to a receiving end, comprising: receiving a fifth directory file sent by a sending end; extracting a fourth verification value from a set position of a file name of a fifth version file included in the fifth directory file; the fifth version file includes a version number of the fifth directory file and a third verification value for verifying whether a version of the fifth directory file is the same as a version indicated by the version number;

[0012] Deleting the fourth check value in the file name of the fifth version file in the fifth directory file to obtain a sixth directory file; performing a hash operation on the sixth directory file to obtain a fifth hash value;

[0013] When it is determined that the fourth check value is the same as the fifth hash value, a hash operation is performed on the other sub-files of the sixth directory file except the fifth version file with the fourth check value deleted to obtain a sixth hash value; when it is determined that the third check value is the same as the sixth hash value, it is verified that the version of the fifth directory file is the same as the version indicated by the version number.

[0014] In one possible implementation, when it is determined that the fourth check value is different from the fifth hash value or the third check value is different from the sixth hash value, an indication message is sent to the sending end, the indication message carries the version number, and the indication message is used to indicate that the version of the directory file corresponding to the version number sent by the sending end is wrong.

[0015] In another possible implementation, after receiving the fifth directory file, when it is determined that the fifth directory file does not include the fifth version file, a prompt message is triggered, where the prompt message is used to indicate that the fifth directory file lacks the fifth version file.

[0016] In a third aspect, an embodiment of the present application provides a directory version management device, including:

[0017] The determining unit is configured to determine the plurality of first subfiles to be sent.

[0018] A processing unit, configured to perform a hash operation on a plurality of first sub-files to be sent to obtain a first hash value, and obtain a first version file based on the first hash value; wherein the plurality of first sub-files and the first version file constitute a first directory file, and the first version file includes the first hash value and a first version number corresponding to a file group constituted by the plurality of first sub-files; perform a hash operation on the first directory file to obtain a second hash value, and add the second hash value to a set position in the file name of the first version file; wherein the second hash value is used to verify whether the version of the first directory file is the same as the version indicated by the version number in the first version file.

[0019] In a possible implementation, when obtaining the first version file based on the first hash value, the processing unit is further configured to: create a second version file, and save the first hash value and the first version number in the second version file to obtain the first version file.

[0020] In some embodiments, the device further includes: an acquisition unit for acquiring a second directory file, the second directory file including a third version file and the multiple first sub-files; when the processing unit obtains the first version file based on the first hash value, it is also used to: add the first hash value and the first version number to the third version file to obtain the first version file.

[0021] In some embodiments, when acquiring the second directory file, the acquiring unit is further configured to: receive a third directory file, the third directory file including the plurality of second sub-files and a fourth version file; the fourth version file including the second version numbers of the plurality of second sub-files and a first check value for verifying whether the versions of the plurality of second sub-files are the same as the version indicated by the second version number;

[0022] The processing unit is further configured to extract the second check value from a set position of the file name of the fourth version file; delete the second check value from the file name of the fourth version file in the third directory file to obtain a fourth directory file; perform a hash operation on the fourth directory file to obtain a third hash value; when it is determined that the second check value is the same as the third hash value, perform a hash operation on the multiple second sub-files in the fourth directory file to obtain a fourth hash value; when it is determined that the first check value is the same as the fourth hash value, verify that the version of the third directory file is the same as the version indicated by the second version number; and change the content of at least one sub-file among the multiple second sub-files to obtain the multiple first sub-files, so as to obtain the second directory file.

[0023] In a fourth aspect, an embodiment of the present application provides a directory version verification device, which is applied to a receiving end and includes:

[0024] an acquiring unit, configured to receive a fifth directory file sent by a sending end;

[0025] A processing unit is configured to extract a second check value from a set position of a file name of a fifth version file included in the fifth directory file; the fifth version file includes a version number of the fifth directory file and a third check value for verifying whether the version of the fifth directory file is the same as the version indicated by the version number; delete the fourth check value from the file name of the fifth version file in the fifth directory file to obtain a sixth directory file; perform a hash operation on the sixth directory file to obtain a fifth hash value; when it is determined that the fourth check value is the same as the fifth hash value, perform a hash operation on other subfiles in the sixth directory file except for the fifth version file in which the fourth check value is deleted to obtain a sixth hash value; and when it is determined that the third check value is the same as the sixth hash value, verify that the version of the fifth directory file is the same as the version indicated by the version number.

[0026] In one possible implementation, the processing unit is also used to: when it is determined that the fourth check value is different from the fifth hash value or the third check value is different from the sixth hash value, send an indication message to the sending end, the indication message carries the version number, and the indication message is used to indicate that the version of the directory file corresponding to the version number sent by the sending end is wrong.

[0027] In some embodiments, the processing unit is further used to: after receiving the fifth directory file, when it is determined that the fifth directory file does not include the fifth version file, trigger a prompt message, wherein the prompt message is used to indicate that the fifth directory file lacks the fifth version file.

[0028] In a fifth aspect, an embodiment of the present application provides a directory version management device, including:

[0029] a memory for storing program instructions;

[0030] The processor is used to call the program instructions stored in the memory and execute the method described in the first and second aspects and any possible implementation of the first and second aspects according to the obtained program.

[0031] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are run on a computer, the computer executes the method described in the first aspect and any possible implementation of the first aspect, or executes the method described in the second aspect and any possible implementation of the second aspect.

[0032] In the seventh aspect, an embodiment of the present application provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a computer, it implements the method described in the first aspect and any possible implementation of the first aspect, or executes the method described in the second aspect and any possible implementation of the second aspect.

[0033] In addition, the technical effects brought about by any implementation method of the second to seventh aspects can refer to the technical effects brought about by the first aspect and any different implementation method of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0035] Figure 1 A flowchart of a directory version management method proposed in an embodiment of the present application;

[0036] Figure 2 A schematic diagram of a receiving end updating a directory version proposed in an embodiment of the present application;

[0037] Figure 3 A schematic diagram of a directory version management method proposed in an embodiment of the present application;

[0038] Figure 4 A flowchart of a directory version verification method provided in an embodiment of the present application;

[0039] Figure 5 A schematic diagram of a directory version management device proposed in an embodiment of the present application;

[0040] Figure 6 A schematic diagram of a directory version verification device provided in an embodiment of the present application;

[0041] Figure 7 A schematic diagram of another directory version management device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings can be arranged and designed in various different configurations.

[0043] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present application.

[0044] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.

[0045] To facilitate understanding of the solutions proposed in the embodiments of this application, the technical terms involved in this application are first introduced:

[0046] (1) The Interplanetary File System (IPFS) is a network transmission protocol designed to create persistent and distributed storage and sharing of files. It is a content-addressable peer-to-peer hypermedia distribution protocol. The IPFS system is content-addressable and identifies files by generating independent hash values ​​based on their content, rather than by their location. Files with the same content only exist in one copy in the system, saving storage space.

[0047] (2) Content Identifier (CID) is a label used to point to content in IPFS. It does not indicate the storage location of the content, but forms an address based on the content itself to indicate the content itself. Each file stored in the IPFS network has a unique content address (i.e. CID, also called hash address), which is the hash value formed by the algorithm. These hash values ​​are unique, and users can locate the file and access the data by simply accessing the corresponding hash. If the file name or content changes, the hash address (value) will change. CID can be understood as a hash operation based on the file name and content. The CID corresponding to the file with supplementary content or name is different. It should be understood that the CID corresponding to the same file in different IPFS nodes is generally the same. As an example, the hash value of an IPFS file can start with "Qm".

[0048] (3) ipfs add command: used to add a specified file or directory to IPFS. IPFS supports uploading files of any format, including audio, video, documents, compressed files, and other file types. As an example, when adding a file on the IPFS network, add the file path after the ipfs add command, such as ipfs add + file path. When adding a folder, add the -r parameter after the ipfs add command. For example, you can add a folder by using ipfs add -r + folder path.

[0049] When files are transferred between multiple devices or people, it is difficult to prevent different people from intentionally or unintentionally modifying the contents of the file during the operation, or the loss of part of the file content during the file transfer process. Therefore, it is very necessary to verify the correctness and integrity of the file. The md5sum command is used to generate and verify the md5 value of the file. This command can only be used to verify the contents of the file directory, not the file name. The add command in the ipfs system can be used to verify the directory content and file name. The CID value returned by the add command can be used to verify whether the file content has been tampered with. However, when a file has multiple versions, although the CID can be used to verify whether the file content has been tampered with, it is impossible to determine whether the version of the file being transferred is the version that needs to be transferred based on the CID alone. Therefore, it is impossible to detect errors in version file transmission.

[0050] Based on the above problems, the embodiments of the present application propose a directory version management method and device. This solution establishes an association between directory files and directory version numbers and stores them in the version file. Each time a directory file is added, modified, or deleted, the version number corresponding to the directory file is also updated accordingly. By verifying the hash value of the directory, it is possible to determine whether the current directory file version is consistent with the version indicated by the version number in the version file, and then determine whether the directory has been tampered with and whether the directory file is the required version.

[0051] like Figure 1 As shown, an embodiment of the present application provides a directory version management method, which is used to verify whether the version corresponding to the directory content is the same as the version indicated by the version number. The method can be executed by a directory version management device, and the specific process is as follows:

[0052] 101. Perform a hash operation on the multiple first sub-files to be sent to obtain a first hash value, and obtain a first version file based on the first hash value. The multiple first sub-files and the first version file constitute a first directory file, and the first version file includes the first hash value and a first version number corresponding to the file group consisting of the multiple first sub-files.

[0053] 102. Perform a hash operation on the first directory file to obtain a second hash value, and add the second hash value to a set location in the file name of the first version file. The second hash value is used to verify whether the version of the first directory file is the same as the version indicated by the version number in the first version file.

[0054] In the first possible scenario, the management device of the directory version is deployed at the sending end. The initial directory file to be sent only includes multiple first sub-files. Therefore, when the sending end obtains the first version file, it can first generate a version file. For the sake of distinction, the generated version file is called the second version file. Furthermore, the sending end performs a hash operation on the multiple first sub-files to obtain a first hash value. For the sake of description, the first hash value is called hash1. Then, the first version number (such as V0.1.0) corresponding to the file group consisting of hash1 and multiple first sub-files is saved in the second version file to obtain the first version file. It can be understood that the directory file after the initial directory file is generated with the version file and hash1 and the version number are saved is the first directory file. The multiple first sub-files included in the first directory file are the same as those in the initial directory file.

[0055] As an example, the version number corresponding to the file group consisting of multiple first sub-files is added or pre-configured by the administrator of the sending end.

[0056] It should be noted that the version number of the file group consisting of multiple first sub-files can also be understood as the version number of the directory file containing multiple first sub-files. Therefore, it can be understood that the version numbers of the initial directory file and the first directory file are the same.

[0057] In the second possible scenario, the directory version management device is deployed at the relay end. The multiple first sub-files to be sent in the relay end may be files modified by the relay end. In this scenario, a version file already exists in the current directory file. In order to facilitate distinction, the version file of the directory file is referred to as the third version file. The directory version management device performs a hash operation on the multiple first sub-files included in the current directory file to obtain a first hash value, and then saves the first version number and the first hash value corresponding to the file group composed of the multiple first sub-files into the third version file to obtain the first version file. The directory file including the multiple first sub-files and the first version file is referred to as the first directory file. In order to facilitate distinction, the directory file including the third version file and the multiple first sub-files is referred to as the second directory file.

[0058] In some embodiments, a directory file version can be generated by executing a custom command hds hash. When a version file already exists in the directory file, the ignore command can be used to calculate the hash values ​​of other sub-files in the directory file except the version file. The ignore command can be used to ignore a certain file. In an embodiment of the present application, the version file can be ignored by the ignore command to calculate the hash values ​​of other sub-files. Specifically, the directory version management device performs a hash operation on multiple first sub-files in the second directory file through the ignore command to obtain a first hash value (hash1). As an example, hash1 can be a 46-bit string starting with Qm.

[0059] In some embodiments, the relay terminal can modify the sub-files in the received directory file. After the modification, the version numbers of the multiple sub-files will also be modified. Therefore, the version numbers included in the version file in the directory file received by the relay terminal are the version numbers of the file group of the multiple sub-files before the modification. In one embodiment, after determining the version numbers of the file group of the multiple sub-files after the modification, the relay terminal can update the version numbers in the version file, i.e., save the version numbers of the file group of the multiple sub-files after the modification into the version file, and then delete the version numbers of the file group of the multiple sub-files before the modification. In another embodiment, after determining the version numbers of the file group of the multiple sub-files after the modification, the relay terminal can directly save the version numbers of the file group of the multiple sub-files after the modification into the version file without updating the version numbers in the version file.

[0060] As an example, let's take the example of a relay terminal obtaining a second directory file. The second directory file includes a third version file and the multiple first subfiles. The multiple first subfiles may be modified subfiles. After calculating the first hash values ​​of the multiple first subfiles, the relay terminal adds the first version numbers of the multiple first subfiles to the third version file to obtain the first version file.

[0061] In a possible implementation, the relay terminal may receive a directory file from another device. For the sake of distinction, the directory file is referred to as a third directory file. Figure 2As shown, the third directory file includes multiple second subfiles and a fourth version file. After receiving the third directory file, the relay terminal verifies whether the version corresponding to the received third directory file is the same as the version indicated by the version number in the fourth version file. The fourth version file includes the second version numbers of the multiple second subfiles and a first check value for verifying whether the versions of the multiple second subfiles are the same as the versions indicated by the second version numbers. Specifically, the second check value is first extracted from the set location of the file name of the fourth version file. The second check value is then deleted from the file name of the fourth version file in the third directory file to obtain the fourth directory file. A hash operation is then performed on the fourth directory file to obtain a third hash value. When the second check value is the same as the third hash value, a hash operation is performed on the multiple second subfiles in the fourth directory file. For example, the ignore command can be used to ignore the fourth version file in the fourth directory file and only the hash operation is performed on the multiple second subfiles in the fourth directory file to obtain a fourth hash value. When the first check value is the same as the fourth hash value, the version of the third directory file is determined to be the same as the version indicated by the second version number.

[0062] For some possible embodiments, see Figure 2 As shown, the relay terminal can also modify the third directory file to obtain the aforementioned second directory file. As previously mentioned, the second directory file includes the third version file and the multiple first subfiles. As can be seen from the previous description, after verifying the third directory file, the name of the fourth version file is updated. Therefore, the updated fourth version file is referred to as the third version file. The directory file containing the updated version file is referred to as the fourth directory file. It is understood that the fourth directory file includes the third version file and multiple second subfiles. When obtaining the second directory file, the relay terminal can specifically modify the content of at least one of the multiple second subfiles included in the fourth directory file to obtain multiple first subfiles, thereby obtaining the second directory file. Specifically, the second directory file includes multiple first subfiles and the third version file. It should be noted that, for ease of description, the subfile after the content of at least one of the multiple second subfiles has been modified is referred to as the first subfile. It is understood that some second subfiles may have the same content as some first subfiles, while the content of other second subfiles may be modified, meaning that the content of other second subfiles is different from that of other first subfiles.

[0063] Furthermore, before sending out the multiple first sub-files, the relay end adds the modified version number of the file group consisting of the multiple first sub-files and the hash value used to verify the directory to the third version file. Exemplarily, a hash operation is performed on the multiple first sub-files to obtain a first hash value, and a first version file is obtained based on the first hash value; wherein the multiple first sub-files and the first version file constitute a first directory file, and the first version file includes the first hash value and the first version number corresponding to the file group consisting of the multiple first sub-files; then a hash operation is performed on the first directory file to obtain a second hash value, and the second hash value is added to the file name of the first version file to set a position to obtain directory file 1, and then directory file 1 can be sent out.

[0064] Through the above scheme, directory versions can be managed and updated. In this embodiment of the present application, the second hash value hash2 of the directory file is saved in the file name of the version file. When verifying the version of the directory file, the complete directory hash value can be obtained directly from the file name of the version file, without the need to transmit the hash value of the directory file separately. The first hash value and the second hash value can be used to verify whether the version of the directory file is the same as the version indicated by the version number in the version file.

[0065] As an example, the first directory file includes four sub-files and a version file. The sub-files may be of a text file, a word file, or other types of files, which are not limited in this embodiment of the present application. Figure 3 As shown, take the first directory file including four text files as an example, namely Text1-Text4. The name of the version file in the first directory file is VERSION. When the directory version management device manages the version of the first directory file, it first performs a hash operation on Text1-Text4 to obtain a first hash value hash1, and saves the first hash value hash1 and the version number of the first directory file into the version file. Then, a hash operation is performed on the entire first directory file with saved hash1 and version number, that is, Text1-Text4 and the version file to obtain a second hash value hash2. For example, Figure 3 Take the second hash value hash2=QmU6VSVymaVdDwQdA6GJpwpXW44rpzg8857i1yhjY33MdQ as an example. Then the directory version management device renames the VERSION version file. Specifically, the second hash value hash2 can be added to the setting position of the version file name, thereby establishing an association relationship between the first directory file and the version number. Figure 3In the example, adding hash2 to the beginning of the version file name, the name of the renamed version file is hash2.VERSION.

[0066] Combine as follows Figure 4 Another directory version management method provided in an embodiment of the present application is described. This method can be used to verify directory versions. This method is applied to a receiving end or relay end that receives a directory file. For ease of description, the received directory file is referred to as a fifth directory file.

[0067] See also Figure 4 The specific process is as follows:

[0068] 401: Receive the fifth directory file sent by the sending end.

[0069] 402 : Extract a fourth check value from the set location of the file name of the fifth version file included in the fifth directory file.

[0070] In some embodiments, the fifth version file includes a version number of the fifth directory file and a third verification value for verifying whether the version of the fifth directory file is the same as the version indicated by the version number.

[0071] In some embodiments, a custom verification command hds verify can be executed to verify whether the version of the fifth directory file is the same as the version indicated by the version number. Specifically, after receiving the fifth directory file, it is first determined whether there is a fifth version file in the fifth directory file. For example, the file name of the fifth version file can be Qmxxx*.VERSION. If there is a version file named Qmxxx*.VERSION in the fifth directory file, the verification value for verifying the version number is taken out from the set position in the file name of the version file named Qmxxx*.VERSION. For ease of distinction, the verification value taken out from the set position in the file name of the version file named Qmxxx*.VERSION is called the fourth verification value. For example, the fourth verification value taken out from the version file named Qmxxx*.VERSION is Qmxxx*. In some embodiments, the format of the verification value can be a 46-bit string starting with Qm.

[0072] In some embodiments, when it is determined that the fifth directory file does not include the fifth version file, a prompt message is triggered, where the prompt message is used to indicate that the fifth directory file lacks the fifth version file.

[0073] 403 , delete the fourth checksum in the file name of the fifth version file in the fifth directory file to obtain the sixth version file.

[0074] For example, the fifth version file may be named Qmxxx*.VERSION. The fourth checksum of the 46-bit string beginning with Qm is deleted from the set position in the Qmxxx*.VERSION file's file name. The version file with the fourth checksum deleted from its file name is called the sixth version file, and the directory file containing the sixth version file is called the sixth directory file.

[0075] 404. Perform a hash operation on the sixth directory file to obtain a fifth hash value.

[0076] Specifically, when performing a hash operation on the sixth directory file, including the sixth version file and each sub-file in the sixth directory file, hash values ​​of the sixth version file and each sub-file are generated based on the file content and file name corresponding to each sub-file and the sixth version file, and then the fifth hash value hash3 of the sixth directory file is generated based on the hash value and file name of the sixth version file and each sub-file.

[0077] In some embodiments, when the file content of a sub-file is not modified and only the file name is changed, the hash value of the sub-file itself remains unchanged, but it will affect the hash value of the directory file where the sub-file is located. For example, the fifth directory file includes four sub-files, files 1-4, and a VERSION version file. When calculating the fifth hash value of the fifth directory file, the hash values ​​of files 1-4 and the VERSION version file will be returned. The hash values ​​of files 1-4 and the VERSION version file are represented by hash11, hash12, hash13, hash14, and hash15 respectively. When the content of file 1 is not changed and only the name of file 1 is changed, when calculating the fifth hash value of the fifth directory file, the returned hash value hash11 of file 1 remains unchanged, but it will affect the fifth hash value hash5 of the fifth directory file, that is, the fifth hash value hash5 will change.

[0078] In some embodiments, a fifth hash value is obtained by performing a hash operation on the sixth directory file using a read-only command, without updating the hash value in the sixth version file in the sixth directory file. For example, the fifth hash value can be calculated using the only-hash=true command.

[0079] 405 , determine whether the fourth check value is the same as the fifth Hash value.

[0080] When the fourth check value is the same as the fifth Hash value, execute step 406;

[0081] When the fourth check value is different from the fifth Hash value, a check failure message is returned and an indication message is sent to the sending end, indicating that the version of the directory file corresponding to the version number sent by the sending end is incorrect.

[0082] 406 , performing a hash operation on the other sub-files in the sixth directory file except the sixth version file to obtain a sixth hash value.

[0083] 407 , determine whether the third check value is the same as the sixth Hash value.

[0084] When the third check value is the same as the sixth Hash value, the version of the fifth directory file is checked to be the same as the version indicated by the version number, and a check success message is returned indicating that the check is successful; otherwise, a check failure message is returned.

[0085] Based on the same technical concept, Figure 5 The present invention provides a directory version management device 500, which can execute Figure 1 The method flow shown.

[0086] See also Figure 5 As shown, the device specifically includes: a determining unit 501 and a processing unit 502.

[0087] The determining unit 501 is configured to determine the multiple first subfiles to be sent.

[0088] A processing unit 502 is configured to perform a hash operation on multiple first sub-files to be sent to obtain a first hash value, and obtain a first version file based on the first hash value; wherein the multiple first sub-files and the first version file constitute a first directory file, and the first version file includes the first hash value and a first version number corresponding to the file group consisting of the multiple first sub-files; perform a hash operation on the first directory file to obtain a second hash value, and add the second hash value to a set position in the file name of the first version file; wherein the second hash value is used to verify whether the version of the first directory file is the same as the version indicated by the version number in the first version file.

[0089] In some embodiments, when obtaining the first version file based on the first hash value, the processing unit 502 is further configured to: create a second version file, and save the first hash value and the first version number in the second version file to obtain the first version file.

[0090] In some embodiments, the apparatus further includes: an acquiring unit 503, configured to acquire a second directory file, the second directory file including the third version file and the plurality of first sub-files;

[0091] When obtaining the first version file based on the first hash value, the processing unit is further configured to:

[0092] Add the first hash value and the first version number to the third version file to obtain the first version file.

[0093] In some embodiments, when acquiring the second directory file, the acquiring unit 503 is further configured to: receive a third directory file, the third directory file including the plurality of second sub-files and a fourth version file; the fourth version file including the second version numbers of the plurality of second sub-files and a first check value for verifying whether the versions of the plurality of second sub-files are the same as the versions indicated by the second version numbers. The processing unit 502 is further configured to extract the second check value from a set position in the file name of the fourth version file; delete the second check value from the file name of the fourth version file in the third directory file to obtain a fourth directory file; perform a hash operation on the fourth directory file to obtain a third hash value; if it is determined that the second check value is the same as the third hash value, perform a hash operation on the plurality of second sub-files in the fourth directory file to obtain a fourth hash value; if it is determined that the first check value is the same as the fourth hash value, verify that the version of the third directory file is the same as the version indicated by the second version number; and modify the content of at least one sub-file among the plurality of second sub-files to obtain the plurality of first sub-files, thereby obtaining the second directory file.

[0094] Based on the same technical concept, Figure 6 A directory version verification device 600 is shown as an example. The device is applied to a receiving end and can execute Figure 4 The method flow shown.

[0095] See also Figure 6 As shown, the device specifically includes: an acquisition unit 601 and a processing unit 602.

[0096] An acquiring unit 601 is configured to receive a fifth directory file sent by a sending end;

[0097] Processing unit 602 is used to extract a second check value from a set position of the file name of the fifth version file included in the fifth directory file; the fifth version file includes the version number of the fifth directory file and a third check value for verifying whether the version of the fifth directory file is the same as the version indicated by the version number; delete the fourth check value from the file name of the fifth version file in the fifth directory file to obtain a sixth directory file; perform a hash operation on the sixth directory file to obtain a fifth hash value; when it is determined that the fourth check value is the same as the fifth hash value, perform a hash operation on other sub-files in the sixth directory file except the fifth version file in which the fourth check value is deleted to obtain a sixth hash value; when it is determined that the third check value is the same as the sixth hash value, verify that the version of the fifth directory file is the same as the version indicated by the version number.

[0098] In some embodiments, the processing unit 602 is also used to: when it is determined that the fourth check value is different from the fifth hash value or the third check value is different from the sixth hash value, send an indication message to the sending end, the indication message carries the version number, and the indication message is used to indicate that the version of the directory file corresponding to the version number sent by the sending end is wrong.

[0099] In some embodiments, the processing unit 602 is further used to: after receiving the fifth directory file, when it is determined that the fifth directory file does not include the fifth version file, trigger a prompt message, wherein the prompt message is used to indicate that the fifth directory file lacks the fifth version file.

[0100] Based on the same technical concept, the embodiment of the present application also provides a directory version management device 700, such as Figure 7 Shown, including:

[0101] Memory 701, used for storing program instructions;

[0102] The processor 702 is configured to call program instructions stored in the memory and execute the above-mentioned method for determining an alarm event according to the obtained program.

[0103] In the embodiments of the present application, the processor 702 may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present application may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0104] Memory 701 is a kind of non-volatile computer readable storage medium, which can be used for storing non-volatile software programs, non-volatile computer executable programs and modules.Memory 701 can include at least one type of storage medium, for example, can include flash memory, hard disk, multimedia card, card type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), programmable read-only memory (Programmable Read Only Memory, PROM), read-only memory (Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic storage, disk, optical disk, etc. Memory 701 is any other medium that can be used to carry or store the desired program code with instruction or data structure form and can be accessed by a computer, but is not limited thereto. The memory 701 in the embodiment of the present application can also be a circuit or other arbitrarily capable of realizing a storage function, for storing program instructions and / or data.

[0105] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0106] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0107] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0108] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0109] Obviously, those skilled in the art may make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include these modifications and variations.

Claims

1. A method for managing directory versions, characterized in that: include: Performing a hash operation on the multiple first sub-files to be sent to obtain a first hash value, and obtaining a first version file based on the first hash value; wherein the multiple first sub-files and the first version file constitute a first directory file, and the first version file includes the first hash value and a first version number corresponding to the file group consisting of the multiple first sub-files; Perform a hash operation on the first directory file to obtain a second hash value, add the second hash value to a set position in the file name of the first version file, and send the changed first directory file to a relay end or a receiving end, so that the relay end or the receiving end verifies whether the version of the first directory file is the same as the version indicated by the version number in the first version file based on the second hash value at the set position in the file name of the first version file in the received changed first directory file and the first hash value in the first version file.

2. The method according to claim 1, wherein The obtaining a first version file based on the first hash value includes: A second version file is created, and the first hash value and the first version number are saved in the second version file to obtain the first version file.

3. The method according to claim 1, wherein The method further comprises: Acquire a second directory file, where the second directory file includes the third version file and the plurality of first sub-files; The obtaining a first version file based on the first hash value includes: Add the first hash value and the first version number to the third version file to obtain the first version file.

4. The method according to claim 3, wherein Get the second directory files, including: receiving a third directory file, the third directory file including a plurality of second sub-files and a fourth version file; the fourth version file including second version numbers of the plurality of second sub-files and a first check value for verifying whether versions of the plurality of second sub-files are the same as the version indicated by the second version number; Extracting a second check value from a setting position of the file name of the fourth version file; Deleting the second checksum in the file name of the fourth version file in the third directory file to obtain a fourth directory file; Performing a hash operation on the fourth directory file to obtain a third hash value; When it is determined that the second check value is the same as the third Hash value, performing a Hash operation on the plurality of second sub-files in the fourth directory file to obtain a fourth Hash value; When it is determined that the first check value is the same as the fourth Hash value, verifying that the version of the third directory file is the same as the version indicated by the second version number; The content of at least one sub-file among the plurality of second sub-files is modified to obtain the plurality of first sub-files, so as to obtain the second directory file.

5. A directory version verification method, characterized in that: Applied to the receiving end, including: receiving the fifth directory file sent by the sending end; extracting a fourth check value from a set position of a file name of a fifth version file included in the fifth directory file; the fifth version file includes a version number of the fifth directory file and a third check value for verifying whether a version of the fifth directory file is the same as a version indicated by the version number; Deleting the fourth check value in the file name of the fifth version file in the fifth directory file to obtain a sixth directory file; Performing a hash operation on the sixth directory file to obtain a fifth hash value; When it is determined that the fourth check value is the same as the fifth Hash value, performing a hash operation on the other subfiles in the sixth directory file except for the fifth version file in which the fourth check value is deleted to obtain a sixth Hash value; When it is determined that the third check value is the same as the sixth Hash value, it is verified that the version of the fifth directory file is the same as the version indicated by the version number.

6. The method according to claim 5, wherein The method further comprises: When it is determined that the fourth check value is different from the fifth hash value or the third check value is different from the sixth hash value, an indication message is sent to the sending end, where the indication message carries the version number, and the indication message is used to indicate that the version of the directory file corresponding to the version number sent by the sending end is wrong.

7. The method according to claim 5 or 6, wherein: The method further comprises: After receiving the fifth directory file, when it is determined that the fifth directory file does not include the fifth version file, a prompt message is triggered, where the prompt message is used to indicate that the fifth version file is missing from the fifth directory file.

8. A directory version management device, characterized in that: include: a determining unit, configured to determine a plurality of first subfiles to be sent; A processing unit is used to perform a hash operation on multiple first sub-files to be sent to obtain a first hash value, and obtain a first version file based on the first hash value; wherein the multiple first sub-files and the first version file constitute a first directory file, and the first version file includes the first hash value and the first version number corresponding to the file group constituted by the multiple first sub-files; perform a hash operation on the first directory file to obtain a second hash value, add the second hash value to a set position in the file name of the first version file, and send the changed first directory file to a relay end or a receiving end, so that the relay end or the receiving end verifies whether the version of the first directory file is the same as the version indicated by the version number in the first version file based on the second hash value at the set position in the file name of the first version file in the received first directory file and the first hash value in the first version file.

9. A directory version verification device, characterized in that: Applied to the receiving end, including: an acquiring unit, configured to receive a fifth directory file sent by a sending end; A processing unit is configured to extract a second check value from a set position of a file name of a fifth version file included in the fifth directory file; the fifth version file includes a version number of the fifth directory file and a third check value for verifying whether the version of the fifth directory file is the same as the version indicated by the version number; delete the fourth check value from the file name of the fifth version file in the fifth directory file to obtain a sixth directory file; perform a hash operation on the sixth directory file to obtain a fifth hash value; when it is determined that the fourth check value is the same as the fifth hash value, perform a hash operation on other subfiles in the sixth directory file except for the fifth version file in which the fourth check value is deleted to obtain a sixth hash value; and when it is determined that the third check value is the same as the sixth hash value, verify that the version of the fifth directory file is the same as the version indicated by the version number.

10. A directory version management device, characterized in that: include: Memory and processor; a memory for storing program instructions; A processor is configured to call the program instructions stored in the memory and execute the method according to any one of claims 1 to 7 according to the obtained program.

Citation Information

Patent Citations

  • Multi-level version format

    US20050256871A1