CN113157302A - Software updating method, device, medium and equipment - Google Patents

Software updating method, device, medium and equipment Download PDF

Info

Publication number
CN113157302A
CN113157302A CN202110566381.XA CN202110566381A CN113157302A CN 113157302 A CN113157302 A CN 113157302A CN 202110566381 A CN202110566381 A CN 202110566381A CN 113157302 A CN113157302 A CN 113157302A
Authority
CN
China
Prior art keywords
file
code
value
version number
javascript
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110566381.XA
Other languages
Chinese (zh)
Other versions
CN113157302B (en
Inventor
陈晟豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202110566381.XA priority Critical patent/CN113157302B/en
Publication of CN113157302A publication Critical patent/CN113157302A/en
Application granted granted Critical
Publication of CN113157302B publication Critical patent/CN113157302B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure relates to the field of software update technology, and provides a software update method, apparatus, medium, and device, the method comprising: renaming the JavaScript file according to a preset rule, wherein the renamed JavaScript file comprises version number information; caching the complete code content of the JavaScript file corresponding to the renamed file by using the local storage of the browser; receiving a JavaScript file acquisition request initiated by a user, and acquiring the information of a required file name and a version number according to a preset rule; judging whether the difference value of the version number information of the updated file and the old version file exceeds a preset threshold value or not; reading all code contents of the version file to be updated, and performing rolling search comparison together with the contents of the old version file; and receiving a result output by rolling search comparison, performing reverse analysis, and performing software updating and splicing.

Description

Software updating method, device, medium and equipment
Technical Field
The present disclosure relates to the field of software update technologies, and more particularly, to a software update method, apparatus, medium, and device.
Background
At present, in the process of product development at the front end, each version needs to modify the related javaScript file, but in the modification process, the modification amount related to the requirement is only a small part of the existing files under most of the situations, and for a user, the user can use the latest files after the latest files are downloaded in a full amount no matter how much the files are modified, so that the user may need to consume more flow to download the files under the condition of frequently publishing and updating the files.
Disclosure of Invention
In order to solve the technical problem that a software updating method in the prior art may consume more traffic, the present disclosure provides a software updating method, including:
renaming the JavaScript file according to a preset rule, wherein the renamed JavaScript file comprises version number information;
caching the complete code content of the JavaScript file corresponding to the renamed file by using the local storage of the browser;
receiving a JavaScript file acquisition request initiated by a user, and acquiring the information of a required file name and a version number according to a preset rule;
judging whether the difference value of the version number information of the updated file and the old version file exceeds a preset threshold value or not;
if the difference value exceeds the value of the version number information of the preset threshold value, returning all data of the file to be updated to the browser without performing incremental calculation processing;
if the difference value is less than or equal to the numerical value of the version number information of the preset threshold value, continuing to calculate the incremental content of the file;
reading all code contents of the version file to be updated, and performing rolling search comparison together with the contents of the old version file;
and receiving a result output by rolling search comparison, performing reverse analysis, and performing software updating and splicing.
Further, in the process of renaming the JavaScript file according to a preset rule, after the JavaScript file is updated each time, one is added to the information of the current version number.
Further, caching the complete code content of the JavaScript file corresponding to the renamed file by using the local storage of the browser specifically includes:
judging whether a cache exists in a local storage in the current browser by using Html 5;
if not, requesting all JavaScript files;
and if the JavaScript file is cached, the code version number of the currently cached JavaScript file is taken out, the currently cached JavaScript file is spliced into a file name needing incremental upgrading according to a preset format, and the file name is cached in a local storage in the browser.
Further, the calculating of the file incremental content specifically includes:
and reading all code data of the JavaScript file of the old version through the server browser, and processing the code data.
Further, the process of processing the code data specifically includes:
reading all contents of the old JavaScript file, and removing all line feed characters in the file;
reading the file code content in a segmented manner according to a set length, setting the set length of each segment to be 20, and setting the index value of each segment to be equal to the index of the position of the first character of the current code segment in the whole file content in the reading process;
calculating MD5 value by calculating current code section content;
caching all the calculated MD5 values and corresponding code segment indexes in a map result set, wherein the result set is an array taking MD5 as key values, and the code segment index values with the same MD5 are stored in the array.
Further, the reading all code contents of the version file to be updated and the contents of the old version file to perform rolling search comparison specifically include:
reading all contents of the updated file, and removing all line feed characters;
reading the file code content in a segmented manner according to a set length, setting the set length of each segment to be 20, and setting the index value of each segment to be equal to the index of the position of the first character of the current code segment in the whole file content in the reading process;
calculating the MD5 value of the current code segment content;
checking whether the MD5 value of the current code segment has a record in the old file result set;
if no data with the MD5 value as a key value exists, temporarily storing the first character of the current code segment, simultaneously moving the code starting position forward by one character, and repeating the step of reading the updated file content and starting the rolling matching;
if the data with the MD5 value as the key value exists, the corresponding value is taken out, and according to the index value of the current code segment, the index data with the minimum absolute value from the index difference value in the array is taken as the search result.
All the code character strings which are temporarily stored are taken out and stored in a result set;
storing the searched index value into a result set;
repeating the process until all the updating codes are matched to obtain a complete result set;
after all the matching is finished, further combining the index values in the result set;
and returning the result set after the merging processing to the browser.
Further, the reverse parsing process specifically includes:
creating a new variable to splice all code segments, judging the traversed information, and returning different results according to different traversed information:
if the traversed result is an array, taking out a first numerical value, and finding a corresponding index position in the cached old version code; taking out a second numerical value, and multiplying the numerical value by the set length to be used as the interception length; splicing the code segments at the positions corresponding to the old versions of the local cache into variables by taking the two versions as the basis;
if the traversal result is a single index value, taking out the corresponding code segments from the old code of the local cache according to the index value and the set length and splicing the code segments into the variable;
and if the character string is obtained as a result of traversing, directly splicing the code character string in the code segment.
Further, still include:
and caching the integrated code and the code version number after software updating splicing into a local storage of the browser for next software updating.
To achieve the above technical object, the present disclosure can also provide a software update apparatus, including:
the renaming module is used for renaming the JavaScript file according to a preset rule, wherein the renamed JavaScript file contains version number information;
the storage module is used for caching the complete code content of the JavaScript file corresponding to the renamed file by utilizing the local storage of the browser;
the receiving module is used for receiving a JavaScript file acquisition request initiated by a user and acquiring the information of the required file name and version number according to a preset rule;
the judging module is used for judging whether the difference value of the version number information of the updated file and the old version file exceeds a preset threshold value or not;
if the difference value exceeds the value of the version number information of the preset threshold value, returning all data of the file to be updated to the browser without performing incremental calculation processing;
if the difference value is less than or equal to the numerical value of the version number information of the preset threshold value, continuing to calculate the incremental content of the file;
the rolling searching module is used for reading all code contents of the version file to be updated and performing rolling searching comparison together with the contents of the old version file;
and the inverse analysis module is used for receiving the result output by the rolling search comparison, performing inverse analysis and performing software updating and splicing.
To achieve the above technical objects, the present disclosure can also provide a computer storage medium having a computer program stored thereon, the computer program being for implementing the steps of the software updating method described above when executed by a processor.
To achieve the above technical object, the present disclosure further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the software updating method when executing the computer program.
The beneficial effect of this disclosure does:
(1) the method and the device increase the caching process according to the version number, and do not need to request the file to download for the second time under the condition that the version number is not changed
(2) The method and the device have the advantages that the incremental content of the file is only downloaded for changing the file, and the flow waste is greatly reduced. .
Drawings
Fig. 1 shows a schematic flow diagram of embodiment 1 of the present disclosure;
fig. 2 shows a schematic structural diagram of embodiment 2 of the present disclosure;
fig. 3 shows a schematic structural diagram of embodiment 4 of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
Various structural schematics according to embodiments of the present disclosure are shown in the figures. The figures are not drawn to scale, wherein certain details are exaggerated and possibly omitted for clarity of presentation. The shapes of various regions, layers, and relative sizes and positional relationships therebetween shown in the drawings are merely exemplary, and deviations may occur in practice due to manufacturing tolerances or technical limitations, and a person skilled in the art may additionally design regions/layers having different shapes, sizes, relative positions, as actually required.
The first embodiment is as follows:
as shown in fig. 1:
the present disclosure provides a software updating method, including:
s101, renaming the JavaScript file according to a preset rule, wherein the renamed JavaScript file comprises version number information;
s102, caching the complete code content of the JavaScript file corresponding to the renamed file by utilizing the local storage of the browser;
s103, receiving a JavaScript file acquisition request initiated by a user, and acquiring the information of the required file name and version number according to a preset rule;
s104, judging whether the difference value of the version number information of the updated file and the old version file exceeds a preset threshold value or not;
if the difference value exceeds the value of the version number information of the preset threshold value, returning all data of the file to be updated to the browser without performing incremental calculation processing;
if the difference value is less than or equal to the numerical value of the version number information of the preset threshold value, continuing to calculate the incremental content of the file;
s105, reading all code contents of the file of the version to be updated and performing rolling search comparison together with the contents of the file of the old version;
and S106, receiving the result output by the rolling search comparison, performing reverse analysis, and performing software updating and splicing.
Further, in the process of renaming the JavaScript file according to a preset rule, after the JavaScript file is updated each time, one is added to the information of the current version number.
Further, caching the complete code content of the JavaScript file corresponding to the renamed file by using the local storage of the browser specifically includes:
judging whether a cache exists in a local storage in the current browser by using Html 5;
if not, requesting all JavaScript files;
and if the JavaScript file is cached, the code version number of the currently cached JavaScript file is taken out, the currently cached JavaScript file is spliced into a file name needing incremental upgrading according to a preset format, and the file name is cached in a local storage in the browser.
Further, the calculating of the file incremental content specifically includes:
and reading all code data of the JavaScript file of the old version through the server browser, and processing the code data.
Further, the process of processing the code data specifically includes:
reading all contents of the old JavaScript file, and removing all line feed characters in the file;
reading the file code content in a segmented manner according to a set length, setting the set length of each segment to be 20, and setting the index value of each segment to be equal to the index of the position of the first character of the current code segment in the whole file content in the reading process;
calculating MD5 value by calculating current code section content;
caching all the calculated MD5 values and corresponding code segment indexes in a map result set, wherein the result set is an array taking MD5 as key values, and the code segment index values with the same MD5 are stored in the array.
Further, the reading all code contents of the version file to be updated and the contents of the old version file to perform rolling search comparison specifically include:
reading all contents of the updated file, and removing all line feed characters;
reading the file code content in a segmented manner according to a set length, setting the set length of each segment to be 20, and setting the index value of each segment to be equal to the index of the position of the first character of the current code segment in the whole file content in the reading process;
calculating the MD5 value of the current code segment content;
checking whether the MD5 value of the current code segment has a record in the old file result set;
if no data with the MD5 value as a key value exists, temporarily storing the first character of the current code segment, simultaneously moving the code starting position forward by one character, and repeating the step of reading the updated file content and starting the rolling matching;
if the data with the MD5 value as the key value exists, the corresponding value is taken out, and according to the index value of the current code segment, the index data with the minimum absolute value from the index difference value in the array is taken as the search result.
All the code character strings which are temporarily stored are taken out and stored in a result set;
storing the searched index value into a result set;
repeating the process until all the updating codes are matched to obtain a complete result set;
after all the matching is finished, further combining the index values in the result set;
and returning the result set after the merging processing to the browser.
Further, the reverse parsing process specifically includes:
creating a new variable to splice all code segments, judging the traversed information, and returning different results according to different traversed information:
if the traversed result is an array, taking out a first numerical value, and finding a corresponding index position in the cached old version code; taking out a second numerical value, and multiplying the numerical value by the set length to be used as the interception length; splicing the code segments at the positions corresponding to the old versions of the local cache into variables by taking the two versions as the basis;
if the traversal result is a single index value, taking out the corresponding code segments from the old code of the local cache according to the index value and the set length and splicing the code segments into the variable;
and if the character string is obtained as a result of traversing, directly splicing the code character string in the code segment.
Further, still include:
and caching the integrated code and the code version number after software updating splicing into a local storage of the browser for next software updating.
The technical solution of the first embodiment of the present disclosure is explained in detail below with reference to a specific embodiment:
s1: renaming the JavaScript file according to a preset rule, wherein the renamed JavaScript file comprises version number information, and adding one to the current version number information after the JavaScript file is updated each time.
Specifically, a JavaScript file naming rule is agreed at the front end and the back end of the file system: js, the version number of the first version is 1.0.0, for example:
file name: pulgin-1.0.0.js, the version number is increased by 1 every time a file is updated, and the file is named as: pulgin-1.0.1.js,
and upgrading the JS file by one version number after the JS file is developed and uploaded to the server.
S2: caching version number and corresponding JS file complete code content by using localStorage of browser
localStorage:
In HTML5, a localStorage feature is newly added, which is mainly used as a local storage to solve the problem of insufficient cookie storage space (the storage space of each cookie in the cookie is 4k), and a typical browser in localStorage supports 5M size, which is different in different browsers.
Specifically, H5 is used for judging whether cache exists in localStorage in the current browser;
if not, requesting a full JavaScript file;
and if the cache exists, the code version number of the current cache is taken out and spliced with the file name needing incremental upgrading according to the agreed format.
S3: the method comprises the steps that a user initiates a request for obtaining a JavaScript file, and a server java servlet receives the request initiated by the user and then obtains information of a required file name and a required version number according to a preset rule.
Specifically, the required file name and version are obtained according to the following rules:
(1) obtaining a URL segmentation array according to the '/' segmentation request URL, and taking the data of the last position in the segmentation array, namely the name of the JavaScript file required to be obtained by the current request
(2) Determine if the requesting JavaScript file name contains an underlined '_' symbol
(3) If no underline symbol exists, the request is a full file, full file data of the JavaScript file of the corresponding version is returned to the browser
(4) If the underline symbol is contained, the file name is divided for the second time according to the middle underline '-' and the underline '-' to obtain the version number of the old version file and the version number of the upgraded file, and the subsequent incremental upgrading steps are sequentially carried out.
S4, comparing the difference value of the version number information of the upgrade file and the old file at the server,
if the number value of the version number information exceeds the preset threshold value, returning the total data of the files needing to be upgraded to the browser without performing incremental calculation processing;
and if the difference value is less than or equal to the preset threshold value, performing subsequent file incremental content calculation.
S5: performing file increment content calculation on the JavaScript file:
specifically, all code data of the old-version JavaScript file need to be read through the server, and relevant processing is performed
The processing process of the JavaScript file specifically comprises the following steps:
(1) and reading all contents of the old JavaScript file, and removing all line feed characters in the file.
(2) Reading the file code content in a segmented manner according to a set length, setting the chunk length of each segment to be 20, and reading one segment each time, wherein the index value of each segment is equal to the index of the position of the first character of the current code segment in the whole file content.
(3) Calculating current code segment contents to calculate MD5 values
(4) All the calculated MD5 values, along with the corresponding code section indexes, are cached in a map result set, where MD5 is used as key, and value is an array, where the code section index values with the same MD5 are stored.
The format is as follows:
Figure BDA0003080859960000091
s6: the server reads all code contents of the version file to be upgraded and carries out rolling search comparison together with the content result set of the old version file
The specific scrolling search process is as follows:
s6.1: reading all contents of the file and removing all line feed characters.
S6.2: reading the code content of the new file in a segmented manner according to a set length, setting the chunk length of each segment to be 20, and reading one segment each time, wherein the index value of each segment is equal to the index of the position of the first character of the current code segment in the whole file content.
S6.3: calculating MD5 value of current code segment content
S6.4: see if the MD5 value of the current code fragment has a record in the old file result set
S6.5: if there is no data with the MD5 value as key, the first character of the current code segment is temporarily stored while the code start position is moved forward by one character, and the scrolling matching S6.6 from step S6.1 is repeated: if data with the MD5 value as key exists, the corresponding value, namely the code segment index array of the old file, is taken out. And according to the index value of the current code segment, taking the index data with the minimum absolute value from the index difference value in the array as a search result.
S6.7: all the code character strings temporarily stored in the step S6.4 are taken out and stored in a result set ArrayList
S6.8: and saving the index value searched in the S6.5 step into a result set ArrayList.
S6.9: and repeating the process until all the code ends are matched to obtain a complete result set.
S6.10: after all the matching is finished, the index values in the result set are further merged, namely, the continuous adjacent indexes are merged into an array with two data, the first value is the code segment index of the old file, and the second value is the number of the continuous code segments.
S6.11: and the server returns the merged result set to the browser.
To take a simplified example, as follows:
(1) assume that the old file code is all: ,
function onError(){
return true;
};
(2) the new file code has the following whole contents:
function onError1(){
return false;
};
(3) assuming that the length of chunk length is 5, the result set of code segments after the segmentation of the old file is
Figure BDA0003080859960000111
(4) After the rolling search comparison process is finished, the obtained result set ArrayList is
[0,5,10,‘r1(){’,20,‘n fals’,30]
(5) Further combined to obtain a result set of
[[0,3],‘r1(){’,20,‘n fals’,30]
S7: after the HTML5 terminal receives the data, the reverse analysis flow is started after traversing the result set
Wherein, the reverse analysis process specifically comprises:
creating a new variable to splice all code segments and judging the traversal information:
if the traversed result is an array, taking out a first numerical value, and finding a corresponding index position in the cached old version code; taking out a second numerical value, and multiplying the numerical value by the length of the fixed segment chunk length to be used as the intercepting length; and splicing the intercepted code segments at the positions corresponding to the old versions of the local cache into variables by taking the two versions as the basis.
And if the traversal result is a single index value, taking out the corresponding code segments from the locally cached old code according to the index value and the given segment length and splicing the code segments into the variable.
And if the character string is obtained as a result of traversing, directly splicing the code character string in the code segment.
S8: after splicing is completed, the complete code and the code version number are cached in localStorage of the browser and are used for next updating.
S9: and calling the eval function at the HTML5 end to explain the complete code spliced in the execution variable, and ending the whole flow.
eval () is a function in program language, the function is to get the return value, different languages are largely the same and slightly different, the function prototype is the return value eval (codestring), if the eval function encounters an error in execution, an exception is thrown to the caller.
Example two:
as shown in figure 2 of the drawings, in which,
the present disclosure can also provide a software updating apparatus including:
the renaming module 201 is configured to rename the JavaScript file according to a preset rule, where the renamed JavaScript file includes version number information;
the storage module 202 is configured to cache complete code content of a JavaScript file corresponding to the renamed file by using local storage of the browser;
the receiving module 203 is configured to receive a request for obtaining a JavaScript file initiated by a user, and obtain information of a required filename and version number according to a preset rule;
the judging module 204 is configured to judge whether a difference between version number information of the updated file and version number information of the old file exceeds a preset threshold;
if the difference value exceeds the value of the version number information of the preset threshold value, returning all data of the file to be updated to the browser without performing incremental calculation processing;
if the difference value is less than or equal to the numerical value of the version number information of the preset threshold value, continuing to calculate the incremental content of the file;
the rolling search module 205 is configured to read all code contents of the version file to be updated, and perform rolling search comparison together with the contents of the old version file;
and the inverse analysis module 206 is configured to receive a result output by the rolling search comparison, perform inverse analysis, and perform software update splicing.
The renaming module 201 is sequentially connected to the storage module 202, the receiving module 203, the determining module 204, the rolling search module 205, and the inverse parsing module 206.
Example three:
the present disclosure can also provide a computer storage medium having stored thereon a computer program for implementing the steps of the software updating method described above when executed by a processor.
The computer storage medium of the present disclosure may be implemented using semiconductor memory or magnetic core memory.
Semiconductor memories are mainly used as semiconductor memory elements of computers, and there are two types, Mos and bipolar memory elements. Mos devices have high integration, simple process, but slow speed. The bipolar element has the advantages of complex process, high power consumption, low integration level and high speed. NMos and CMos were introduced to make Mos memory dominate in semiconductor memory. NMos is fast, e.g. 45ns for 1K bit sram from intel. The CMos power consumption is low, and the access time of the 4K-bit CMos static memory is 300 ns. The semiconductor memories described above are all Random Access Memories (RAMs), i.e. read and write new contents randomly during operation. And a semiconductor Read Only Memory (ROM), which can be read out randomly but cannot be written in during operation, is used to store solidified programs and data. The ROM is classified into a non-rewritable fuse type ROM, PROM, and a rewritable EPROM.
The magnetic core memory has the characteristics of low cost and high reliability, and has more than 20 years of practical use experience. Magnetic core memories were widely used as main memories before the mid 70's. The storage capacity can reach more than 10 bits, and the access time is 300ns at the fastest speed. The typical international magnetic core memory has a capacity of 4 MS-8 MB and an access cycle of 1.0-1.5 mus. After semiconductor memory is rapidly developed to replace magnetic core memory as a main memory location, magnetic core memory can still be applied as a large-capacity expansion memory.
Example four:
the present disclosure also provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the steps of the software updating method are implemented.
Fig. 3 is a schematic diagram of an internal structure of an electronic device in one embodiment. As shown in fig. 3, the electronic device includes a processor, a storage medium, a memory, and a network interface connected through a system bus. The storage medium of the computer device stores an operating system, a database and computer readable instructions, the database can store control information sequences, and the computer readable instructions can make a processor realize a software updating method when being executed by the processor. The processor of the electrical device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may have stored therein computer readable instructions that, when executed by the processor, may cause the processor to perform a software update method. The network interface of the computer device is used for connecting and communicating with the terminal. Those skilled in the art will appreciate that the architecture shown in fig. 3 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
The electronic device includes, but is not limited to, a smart phone, a computer, a tablet, a wearable smart device, an artificial smart device, a mobile power source, and the like.
The processor may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor is a Control Unit of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device by running or executing programs or modules (for example, executing remote data reading and writing programs, etc.) stored in the memory and calling data stored in the memory.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connected communication between the memory and at least one processor or the like.
Fig. 3 shows only an electronic device having components, and those skilled in the art will appreciate that the structure shown in fig. 3 does not constitute a limitation of the electronic device, and may include fewer or more components than those shown, or some components may be combined, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor through a power management device, so that functions such as charge management, discharge management, and power consumption management are implemented through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used to establish a communication connection between the electronic device and other electronic devices.
Optionally, the electronic device may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
Further, the computer-usable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.

Claims (10)

1. A software update method, comprising:
renaming the JavaScript file according to a preset rule, wherein the renamed JavaScript file comprises version number information;
caching the complete code content of the JavaScript file corresponding to the renamed file by using the local storage of the browser;
receiving a JavaScript file acquisition request initiated by a user, and acquiring the information of a required file name and a version number according to a preset rule;
judging whether the difference value of the version number information of the updated file and the old version file exceeds a preset threshold value or not;
if the difference value exceeds the value of the version number information of the preset threshold value, returning all data of the file to be updated to the browser without performing incremental calculation processing;
if the difference value is less than or equal to the numerical value of the version number information of the preset threshold value, continuing to calculate the incremental content of the file;
reading all code contents of the version file to be updated, and performing rolling search comparison together with the contents of the old version file;
and receiving a result output by rolling search comparison, performing reverse analysis, and performing software updating and splicing.
2. The method of claim 1, wherein in renaming the JavaScript file according to a preset rule, one is added to the current version number information each time the JavaScript file is updated.
3. The method of claim 1, wherein caching the complete code content of the JavaScript file corresponding to the renamed file by using the local storage of the browser specifically comprises:
judging whether a cache exists in a local storage in the current browser by using Html 5;
if not, requesting all JavaScript files;
and if the JavaScript file is cached, the code version number of the currently cached JavaScript file is taken out, the currently cached JavaScript file is spliced into a file name needing incremental upgrading according to a preset format, and the file name is cached in a local storage in the browser.
4. The method according to claim 1, wherein the file delta content calculation specifically comprises:
reading all contents of the old JavaScript file, and removing all line feed characters in the file;
reading the file code content in a segmented manner according to a set length, setting the set length of each segment to be 20, and setting the index value of each segment to be equal to the index of the position of the first character of the current code segment in the whole file content in the reading process;
calculating MD5 value by calculating current code section content;
caching all the calculated MD5 values and corresponding code segment indexes in a map result set, wherein the result set is an array taking MD5 as key values, and the code segment index values with the same MD5 are stored in the array.
5. The method according to claim 1, wherein the reading of all code contents of the file to be updated and the performing of the rolling search comparison together with the contents of the old version of the file specifically comprises:
reading all contents of the updated file, and removing all line feed characters;
reading the file code content in a segmented manner according to a set length, setting the set length of each segment to be 20, and setting the index value of each segment to be equal to the index of the position of the first character of the current code segment in the whole file content in the reading process;
calculating the MD5 value of the current code segment content;
checking whether the MD5 value of the current code segment has a record in the old file result set;
if no data with the MD5 value as a key value exists, temporarily storing the first character of the current code segment, simultaneously moving the code starting position forward by one character, and repeating the step of reading the updated file content and starting the rolling matching;
if the data with the MD5 value as the key value exists, the corresponding value is taken out, and according to the index value of the current code segment, the index data with the minimum absolute value from the index difference value in the array is taken as the search result.
All the code character strings which are temporarily stored are taken out and stored in a result set;
storing the searched index value into a result set;
repeating the process until all the updating codes are matched to obtain a complete result set;
after all the matching is finished, further combining the index values in the result set;
and returning the result set after the merging processing to the browser.
6. The method of claim 1, wherein the reverse parsing process specifically comprises:
creating a new variable to splice all code segments, judging the traversed information, and returning different results according to different traversed information:
if the traversed result is an array, taking out a first numerical value, and finding a corresponding index position in the cached old version code; taking out a second numerical value, and multiplying the numerical value by the set length to be used as the interception length; splicing the code segments at the positions corresponding to the old versions of the local cache into variables by taking the two versions as the basis;
if the traversal result is a single index value, taking out the corresponding code segments from the old code of the local cache according to the index value and the set length and splicing the code segments into the variable;
and if the character string is obtained as a result of traversing, directly splicing the code character string in the code segment.
7. The method of any one of claims 1 to 6, further comprising:
and caching the integrated code and the code version number after software updating splicing into a local storage of the browser for next software updating.
8. A software update apparatus, comprising:
the renaming module is used for renaming the JavaScript file according to a preset rule, wherein the renamed JavaScript file contains version number information;
the storage module is used for caching the complete code content of the JavaScript file corresponding to the renamed file by utilizing the local storage of the browser;
the receiving module is used for receiving a JavaScript file acquisition request initiated by a user and acquiring the information of the required file name and version number according to a preset rule;
the judging module is used for judging whether the difference value of the version number information of the updated file and the old version file exceeds a preset threshold value or not;
if the difference value exceeds the value of the version number information of the preset threshold value, returning all data of the file to be updated to the browser without performing incremental calculation processing;
if the difference value is less than or equal to the numerical value of the version number information of the preset threshold value, continuing to calculate the incremental content of the file;
the rolling searching module is used for reading all code contents of the version file to be updated and performing rolling searching comparison together with the contents of the old version file;
and the inverse analysis module is used for receiving the result output by the rolling search comparison, performing inverse analysis and performing software updating and splicing.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the steps of the method according to any of claims 1 to 7 are performed when the computer program is executed by the processor.
10. A computer storage medium having computer program instructions stored thereon, wherein the program instructions, when executed by a processor, are adapted to implement the corresponding steps of the software update method as claimed in any one of claims 1 to 7.
CN202110566381.XA 2021-05-24 2021-05-24 Software updating method, device, medium and equipment Active CN113157302B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110566381.XA CN113157302B (en) 2021-05-24 2021-05-24 Software updating method, device, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110566381.XA CN113157302B (en) 2021-05-24 2021-05-24 Software updating method, device, medium and equipment

Publications (2)

Publication Number Publication Date
CN113157302A true CN113157302A (en) 2021-07-23
CN113157302B CN113157302B (en) 2022-11-04

Family

ID=76877654

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110566381.XA Active CN113157302B (en) 2021-05-24 2021-05-24 Software updating method, device, medium and equipment

Country Status (1)

Country Link
CN (1) CN113157302B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050102669A1 (en) * 2003-10-15 2005-05-12 Siemens Medical Solutions Usa, Inc. Software installation file verification media and methods for medical equipment
CN102184112A (en) * 2011-05-06 2011-09-14 北京百度网讯科技有限公司 Method and device for upgrading widget
CN103701856A (en) * 2013-11-29 2014-04-02 四川长虹电器股份有限公司 Method for defining and acquiring upgrade package of terminal equipment
CN104539696A (en) * 2014-12-26 2015-04-22 北京像素软件科技股份有限公司 Client end incremental updating method and system
CN106648712A (en) * 2017-02-27 2017-05-10 百度在线网络技术(北京)有限公司 Incremental updating packet generating method and device, and server
CN111090444A (en) * 2019-12-03 2020-05-01 航天信息股份有限公司 Version upgrading method and device, storage medium and electronic equipment
CN111708566A (en) * 2020-06-10 2020-09-25 深圳云之家网络有限公司 Software increment updating method, device, system and computer readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050102669A1 (en) * 2003-10-15 2005-05-12 Siemens Medical Solutions Usa, Inc. Software installation file verification media and methods for medical equipment
CN102184112A (en) * 2011-05-06 2011-09-14 北京百度网讯科技有限公司 Method and device for upgrading widget
CN103701856A (en) * 2013-11-29 2014-04-02 四川长虹电器股份有限公司 Method for defining and acquiring upgrade package of terminal equipment
CN104539696A (en) * 2014-12-26 2015-04-22 北京像素软件科技股份有限公司 Client end incremental updating method and system
CN106648712A (en) * 2017-02-27 2017-05-10 百度在线网络技术(北京)有限公司 Incremental updating packet generating method and device, and server
CN111090444A (en) * 2019-12-03 2020-05-01 航天信息股份有限公司 Version upgrading method and device, storage medium and electronic equipment
CN111708566A (en) * 2020-06-10 2020-09-25 深圳云之家网络有限公司 Software increment updating method, device, system and computer readable storage medium

Also Published As

Publication number Publication date
CN113157302B (en) 2022-11-04

Similar Documents

Publication Publication Date Title
CN110162522B (en) Distributed data search system and method
CN104794177A (en) Data storing method and device
CN106648569B (en) Target serialization realization method and device
CN111625748B (en) Navigation bar information extraction method and device of website, electronic equipment and storage medium
CN104516920A (en) Data inquiry method and data inquiry system
US20160085875A1 (en) Method for configuring browser bookmarks, device and terminal thereof
CN110309457B (en) Webpage data processing method, device, computer equipment and storage medium
CN110309386B (en) Method and device for crawling web page
CN111552640A (en) Code detection method, device, equipment and storage medium
CN113282854A (en) Data request response method and device, electronic equipment and storage medium
CN112650909A (en) Product display method and device, electronic equipment and storage medium
CN111858612B (en) Data accelerated access method and device based on graph database and storage medium
CN113157302B (en) Software updating method, device, medium and equipment
CN103150355A (en) Web page content preview method and device, and equipment
CN112256472A (en) Distributed data calling method and device, electronic equipment and storage medium
CN115795521B (en) Access control method, device, electronic equipment and storage medium
CN115827115A (en) H5 page jump method, device, equipment and storage medium of WeChat applet
CN113065086A (en) Webpage text extraction method and device, electronic equipment and storage medium
CN115186188A (en) Product recommendation method, device and equipment based on behavior analysis and storage medium
CN112230989B (en) Webpage channel navigation bar extraction method, system, electronic equipment and storage medium
CN114936111A (en) Front-end variable anomaly detection and restoration method, device, equipment and storage medium
CN114048847A (en) Method, device and equipment for caching graph neural network data and storage medium
CN114518993A (en) System performance monitoring method, device, equipment and medium based on business characteristics
CN114357337A (en) Cache management method, device, equipment and storage medium
CN113139145A (en) Page generation method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant