WO2022036927A1 - File storage method and apparatus, device, and medium - Google Patents

File storage method and apparatus, device, and medium Download PDF

Info

Publication number
WO2022036927A1
WO2022036927A1 PCT/CN2020/133445 CN2020133445W WO2022036927A1 WO 2022036927 A1 WO2022036927 A1 WO 2022036927A1 CN 2020133445 W CN2020133445 W CN 2020133445W WO 2022036927 A1 WO2022036927 A1 WO 2022036927A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
data
index data
target
storage
Prior art date
Application number
PCT/CN2020/133445
Other languages
French (fr)
Chinese (zh)
Inventor
董遇生
Original Assignee
安徽鸿程光电有限公司
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 安徽鸿程光电有限公司 filed Critical 安徽鸿程光电有限公司
Publication of WO2022036927A1 publication Critical patent/WO2022036927A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of data processing, and in particular, to a file storage method, apparatus, device and medium.
  • the data and various resources of the multimedia file are generally packaged into a compressed file and stored on a disk.
  • the multimedia file is courseware
  • the user modifies part of the courseware and needs to save it again the latest data file and various resources need to be repackaged to generate a new compressed file.
  • the compressed file generated is also very large, and it takes a long time to save the modified file each time.
  • the present application provides a file storage method, device, device and computer storage medium, which can solve the problem of low file storage efficiency.
  • the present application provides a file storage method, which may include:
  • the modification information of the original file is obtained, wherein the target file is a modified file of the original file, and the storage file of the original file may include at least one data file and the target index corresponding to the at least one data file data;
  • Determine the newly written data based on the modification information, and the newly written data may at least include the updated target index data
  • the present application provides a file storage device, the device may include:
  • the modification information obtaining module is used to obtain modification information of the original file in response to the storage request for the target file, wherein the target file is a modified file of the original file, and the storage file of the original file may include at least one data file and at least one data file.
  • the target index data corresponding to a data file
  • a newly written data determination module configured to determine newly written data based on the modification information, and the newly written data may at least include updated target index data;
  • the storage module is used to replace the target index data with newly written data to obtain the storage file of the target file.
  • the present application provides a file storage device, the device may include: a processor and a memory storing computer program instructions;
  • the file storage method provided in the first aspect can be implemented.
  • the present application provides a computer storage medium, where computer program instructions are stored thereon, and when the computer program instructions are executed by a processor, the file storage method provided in the first aspect can be implemented.
  • newly written data can be determined based on the modification information of the original file.
  • the newly written data may at least include updated target index data.
  • Fig. 1 is the structural representation of the courseware provided according to the application.
  • Fig. 2 is the structural representation of the storage file of the original courseware provided according to the application;
  • FIG. 3 is a schematic flowchart of an embodiment of a file storage method provided according to the present application.
  • FIG. 4 is a schematic structural diagram of an embodiment of a storage file of a target file provided according to the present application.
  • FIG. 5 is a schematic structural diagram of another embodiment of a storage file of a target file provided according to the present application.
  • FIG. 6 is a schematic structural diagram of an embodiment of a file storage device provided according to the present application.
  • FIG. 7 is a schematic structural diagram of an embodiment of a file storage device provided according to the present application.
  • the multimedia file may be a PPT (PowerPoint) file.
  • PPT software is a presentation graphics software, mainly used for making slides.
  • the software is capable of creating vivid visual effects and supports multimedia functions.
  • the speaker of the conference can use the conference file made by the PPT software to present the lecture content to the participants.
  • teachers can use the courseware made by PPT software to teach.
  • the courseware can be course software produced according to the requirements of the teaching syllabus, through the determination of teaching objectives, the analysis of teaching content and tasks, the structure of teaching activities and the design of interface.
  • FIG. 1 is a schematic structural diagram of the courseware provided by this application.
  • the courseware generally consists of three types of data files: "main data file, page data file, and resource data file".
  • the data formats of the main data file and the page data file are, for example, Extensible Markup Language (Extensible Markup Language, XML) format.
  • the master data file may include the overall style data of the courseware, the total number of pages, and so on.
  • the page data file may include page layout data and text data of the current page and other data.
  • the resource data file may include pictures, audio, video and other files in the courseware page.
  • the page data file corresponds to a page of a courseware, that is, the number of page data files corresponds to the number of pages of the courseware.
  • the number of resource data files is related to the number of pictures, audio, video and other resources used by each page in the courseware.
  • the ZIP file format is a file format for data compression and document storage. As shown in Figure 2, a ZIP file is mainly composed of three parts, the file data storage area, the central directory structure area and the central directory end area.
  • the file data storage area is used to save the general information and file content of each data file in the courseware.
  • the file data storage area includes n data files: data file 1, data file 2, ..., data file n.
  • n is a positive integer.
  • the central directory structure area is used to save the index data of each data file in the courseware.
  • the index data of each data file may include the summary information of the data file, the offset address of the data file relative to the first address in the ZIP file, and the file length of the data file and other information.
  • the central directory end area is used to save the index data of the index data of each data file in the central directory structure area.
  • the central directory end area is used to save the number of index data in the central directory structure area (ie the number of central directories n), and the offset address of the index data of each data file relative to the first address in the ZIP file (ie the central directory number n) directory offset) and the total length of the data in the central target structure area (ie, the central directory length).
  • Most of the data of the ZIP file is located in the "file data storage area”, and only a small part of the data is located in the "central directory structure area" and "central directory end area".
  • the present application provides a file storage method, which can improve the storage efficiency of modified files.
  • the file storage method provided by the present application will be described in detail below with reference to specific embodiments and accompanying drawings.
  • FIG. 3 is a schematic flowchart of an embodiment of a file storage method provided by the present application.
  • the file storage method 300 provided by the present application may include:
  • Step 310 in response to the storage request for the target file, obtain the modification information of the original file, wherein, the target file is the modified file of the original file, and the storage file of the original file may include at least one data file corresponding to at least one data file. the target index data;
  • Step 320 determining newly written data based on the modification information, and the newly written data may at least include updated target index data;
  • Step 330 Replace the target index data with newly written data to obtain a storage file of the target file.
  • step 310 the specific implementation of step 310 is introduced.
  • the original file may be a PPT file.
  • the PPT file may include, for example, courseware, conference files, and other files. During use of the original file, modifications to the original file may be required.
  • the target file is the modified file from the original file.
  • Case 1 Modify the content of the existing page in the original courseware.
  • modifying the content of the existing pages in the original courseware may include: adding new data to the existing pages in the original courseware, deleting existing data in the existing pages in the original courseware, modifying the existing pages in the original courseware There are page data and so on. Among them, modifying the data of the existing page in the original courseware can be converted into deleting the existing data in the page and adding new data to the page.
  • the modification to the content of the existing page in the original courseware can be expressed as the deletion of the original page data file of the existing page and the addition of the new page data file of the modified existing page.
  • the modification information to the original file may include the identifiers of the new page data file of the newly added modified existing page and the original page data file of the deleted existing page.
  • adding a new page to the original courseware can be represented as adding a page data file of the new page and adding a resource data file corresponding to the new page. It should be noted that if a new page is added to the original courseware, the master data file will also be updated (the record of this page is added). Therefore, adding new pages to the original courseware also manifests as deletion of the original master data file of the original courseware and addition of the updated master data file.
  • the modification information to the original file may include the page data file of the newly added new page, the resource data file corresponding to the newly added new page, and the original master data of the deleted original courseware The identification of the file and the new updated master data file.
  • deleting a page in the original courseware may be expressed as deleting the original page data file of the page and the original resource data file corresponding to the page. It should be noted that if the page in the original courseware is deleted, the master data file will also be updated (delete the record of the page). Therefore, the deletion of the pages in the original courseware also manifests as deletion of the original master data file of the original courseware and addition of the updated master data file.
  • the modification information to the original file may include the identifier of the original page data file of the deleted page, the identifier of the original resource data file corresponding to the deleted page, and the original master data of the deleted original courseware The identification of the file and the new updated master data file.
  • the modification of the original courseware for example, is to add, delete or modify elements in the page in the courseware, or to add or delete pages, these modification operations are finally reflected as changes to the main data file,
  • the addition, deletion or modification of three types of data files are the storage granularity when courseware is saved to disk.
  • the modification of data files can be converted into deletion of existing data files and addition of new data files. Therefore, modifications to the original file may include deletion of existing data files in the original file and addition of new data files. In this way, the modification information to the original file may include identifiers of newly added data files and deleted data files.
  • the user can send a storage request for the target file through the device where the original file is located.
  • the device where the original file is located may obtain the acquisition time of the storage request.
  • all operation records of the original file between the acquisition time of the storage request and the preservation time of the original file can be obtained.
  • it can be counted which data files have changed after the original file has been modified.
  • the identifiers of the newly added data file and the deleted data file can be obtained, and then the modification information of the original file can be obtained.
  • the storage file of the original file may be the final file corresponding to when the original file is stored to the disk.
  • the storage file of the original file may include at least one data file and target index data corresponding to the at least one data file.
  • at least one data file may include a main data file, a page data file and a resource data file in the original file.
  • the target index data corresponding to at least one data file may include first index data and second index data.
  • the first index data may include index data of each data file in the at least one data file stored in the central target structure area shown in FIG. 2 .
  • the second index data may include index data of the first index data, that is, data in the end area of the central directory shown in FIG. 2 .
  • step 320 The specific implementation manner of step 320 is described below.
  • the modification information to the original file may include an identifier of a newly added data file and/or a deleted data file. Regardless of whether the modification information includes an identifier of a newly added data file or an identifier of a deleted data file, the target index data needs to be updated based on the modification information of the original file. Therefore, the newly written data may include at least the updated target index data.
  • the updated target index data is, for example, updated based on the modification information of the original file.
  • the target index data may be updated based on the identifier of the data file to be deleted, and the updated target index data may be used as newly written data, and the storage of the target file may also be implemented.
  • step 320 may include step 3201 and step 3202 .
  • Step 3201 in the case that the modification information includes the newly added data file, obtain the updated target index data based on the modification information, and determine the newly added data file and the updated target index data as newly written data;
  • Step 3202 in the case that the modification information includes the identifier of the deleted data file, obtain the updated target index data based on the modification information, and determine the updated target index data as newly written data.
  • the modification information to the original file includes a newly added data file
  • the newly added data file needs to be written after the file data storage area. If the newly added data file is written after the file data storage area, the index data of the newly added data file needs to be added to the first index data in the central directory structure area. Since new index data is added to the first index data in the central directory structure area, the second index data in the central directory end area also needs to be updated accordingly, that is, the target index data needs to be updated based on the newly added data file. Therefore, the newly written data includes newly added data files and updated target index data.
  • the modification information of the original file includes the identifier of the deleted data file
  • the index data of the data files to be deleted may be removed from the first index data of the central directory structure area. Since part of the index data is deleted from the first index data in the central directory structure area, the second index data in the central directory end area also needs to be updated accordingly. That is to say, the target index data needs to be updated based on the identifier of the deleted data file, so as to realize the deletion of the index data of the data file to be deleted, that is, mark deletion.
  • the target index data may include first index data and second index data
  • the first index data may include index data of each data file in the at least one data file
  • the second index data may include the first index data Index data for index data.
  • obtaining the updated target index data may include steps A to C.
  • Step A update the first index data based on the modification information, and obtain the updated first index data
  • Step B update the second index data according to the updated first index data, and obtain the updated second index data
  • Step C and determine the updated first index data and the updated second index data as the updated target index data.
  • step A if the modified data file includes the newly added data file, the index data of the newly added data file is added to the first index data to obtain the updated first index data.
  • step A when the modified data file includes the identifier of the deleted data file, the index data of the deleted data file corresponding to the identifier is deleted from the first index data to obtain the updated first index data.
  • step A in the case that the modified data file includes a newly added data file and a deleted data file, the index data of the newly added data file is added from the first index data and the identifier is deleted from the first index data The index data of the corresponding deleted data file is obtained to obtain the updated first index data.
  • the central directory end area Since the second index data stored in the central directory end area includes the index data of the first index data in the central directory structure area, for example, the central directory end area is used to store the number of index data in the central directory structure area, and each data The index data of the file is relative to the offset address of the first address in the ZIP file and the total data length of the index data in the central directory structure area. Therefore, in step B, if the index data of the data file appears in the first index data. addition or deletion, the second index data needs to be updated along with the update of the first index data.
  • the updated first index data includes the index data of the newly added data file
  • the number of index data in the central directory structure area increases accordingly, and the index data of each data file is relative to the first address in the ZIP file.
  • the offset address of then moves backward, and the total data length of the first index data increases accordingly, thereby obtaining the updated second index data.
  • step C after both the first index data and the second index data are updated, the updated first index data and the updated second index data are determined as the updated target index data.
  • step 330 includes: under the condition of keeping at least one data file unchanged, replacing the target index data with newly written data to obtain a storage file of the target file.
  • the modification of the original file is actually the deletion and addition of the data file.
  • the newly added data file it can be appended after the file content of the storage file of the original file.
  • the deleted data files can be processed by deleting the index data of the data files to be deleted, so that the existing data files in the storage files of the original files can be reused, and only the deleted data files and newly added data files can be processed. data files.
  • users modify courseware they usually only modify a small part of the content, and most of the content remains unchanged, so the changed data is much less than the unchanged data. Therefore, using the file storage method provided by this application can significantly improve the preservation of files. speed.
  • FIG. 4 is a schematic diagram of a storage file of a target file provided by the present application.
  • the dot-dash line frame is at least one data file included in the storage file of the original file.
  • the newly written data is added at the end of the file data storage area.
  • the newly written data may include three parts: the newly added data file in the file data storage area, the updated first index data in the new central directory structure area, and the updated first index data in the new central directory end area The second index data.
  • the modification information to the original file may include the newly added data file n+1.
  • the updated first index data may include the first index data in the target index data and the index data of the newly added data file n+1. That is to say, a new "central directory structure area" is formed after adding the index data of the newly added data file n+1 to the original "central directory structure area" in the storage file of the original file.
  • the number of central directories is updated to n+1, and the central directory offset and the central directory length are updated to obtain updated second index data. That is, on the basis of the original "central directory end area" in the storage file of the original file, the number of central directories, the central directory offset and the central directory length are updated to obtain a new "central directory end area".
  • FIG. 2 is a schematic diagram of the storage file of the original file.
  • the storage file of the target file shown in FIG. 4 the data files 1 to n in the dotted line frame remain unchanged, and then the file data of the storage file of the original file is stored in the original file. After the storage area, the newly written data in the dotted box in FIG. 4 is added.
  • the storage file of the target file in FIG. 4 has newly added data file n+1 shown in the gray area, and the index data of the data file n+1.
  • the storage file of the target file in FIG. 4 is compared with the original storage file in FIG. 2, and the central directory offset, the central directory length and the central directory number shown in the gray area are modified.
  • FIG. 5 is a schematic diagram of a storage file of a target file provided by the present application.
  • the dot-dash line frame is at least one data file included in the storage file of the original file.
  • the newly written data is the newly written data.
  • the newly written data may include two parts: the updated first index data in the new central directory structure area and the updated second index data in the new central directory end area.
  • the modification information to the original file may include the identifier of the deleted data file 2 .
  • the updated first index data may include data after the index data of the data file 2 is deleted from the first index data in the target index data. That is to say, a new "central directory structure area" is formed after deleting the index data of the data file 2 on the basis of the original "central directory structure area” in the storage file of the original file.
  • the number of central directories is updated to n-1, and the central directory offset and the central directory length are updated to obtain updated second index data. That is, on the basis of the original "central directory end area" in the storage file of the original file, the number of central directories, the central directory offset and the central directory length are updated to obtain a new "central directory end area".
  • the storage file of the target file in FIG. 5 has the index data of the data file 2 deleted.
  • the storage file of the target file in FIG. 5 is compared with the original storage file in FIG. 2, and the central directory offset, the central directory length and the central directory number shown in the gray area are modified.
  • a list of data files to be deleted and a list of data files to be added can be acquired.
  • the list of data files to be deleted it is only necessary to delete the index data of these files from the "Central Directory Structure Area” and correct the data in the "Central Directory End Area”, and then use the new "Central Directory Structure Area” and "Central Directory Structure Area”
  • the directory end area "overwrites the original "central directory structure area” and the "central directory end area", and the content of the original "file data storage area” remains unchanged.
  • the file storage method proposed in the present application uses an incremental method to save the target file on the basis of the storage file of the original file, and directly modifies the storage file of the original file on the disk instead of generating a copy of the file on the disk for operation, so it can obviously Improve the storage speed of target files, and save too much disk space during the save process.
  • the step 330 includes: in the case of determining that the ratio of the size of the deleted data file corresponding to the identification to the size of the storage file of the original file is greater than the first preset ratio, deleting the deleted data file corresponding to the identification from at least one data file , and replace the target index data with the newly written data to obtain the storage file of the target file.
  • the first preset ratio may be 10%.
  • the ratio of the size of the deleted data file to the size of the storage file of the original file is greater than the first preset In the case of the ratio, the data files to be deleted are deleted from at least one data file, that is, the data in the storage file of the original file is actually deleted, so as to reduce the size of the courseware file.
  • the file storage method provided by the present application may further include: saving the target index data in the memory; and/or storing the target index data in the memory; Index data is kept on disk.
  • the target index data can be backed up.
  • the original "central directory structure area" and "central directory end area” in the storage file of the original file can be backed up by at least one of the following two methods, that is, the target index data is backed up.
  • the first backs up the target index data in memory.
  • the second backs up the target index data on disk.
  • the target index data is stored in the disk, it can be backed up in the directory where the original file storage file is located, and the backup file name can be "original file storage file name.tmp". If saving of the target file is normally completed, the backup file of the target index data is deleted.
  • the storage file of the original file can be located at the starting position of the original "central directory structure area", and the data of the original "central directory structure area” and "central directory end area” of the backup can be written , you can restore the stored files of the original files.
  • the memory backup is used, and the file recovery speed is fast.
  • the computer determines whether the directory where the original file is stored has a file name such as "Stored file name of the original file.tmp" backup file. If there is a backup file whose file name is, for example, "storage file name of the original file. tmp", the backup file is read into the memory. Then, locate the storage file of the original file to the starting position of the original "central directory structure area”, and write the backup data of the original "central directory structure area" and "central directory end area” to restore the storage file of the original file , in this case, the memory backup is used, and the file recovery speed is fast. After the restoration of the storage file of the original file is completed, the backup file of the target index data is deleted, and the restored original file is opened.
  • a file name such as "Stored file name of the original file.tmp" backup file. If there is a backup file whose file name is, for example, "storage file name of the original file. tmp", the backup file is read into the memory. Then, locate the storage file of the
  • FIG. 6 is a schematic structural diagram of an embodiment of a file storage device provided by the present application.
  • the file storage device 600 provided by the present application may include:
  • the modification information obtaining module 610 is configured to obtain modification information of the original file in response to the storage request for the target file, wherein the target file is a modified file of the original file, and the storage file of the original file may include at least one data file and Target index data corresponding to at least one data file;
  • a new write data determination module 620 configured to determine new write data based on the modification information, and the new write data may at least include updated target index data;
  • the storage module 630 is configured to replace the target index data with newly written data to obtain a storage file of the target file.
  • the newly written data when the modified target file is saved, can be determined based on the modification information of the original file.
  • the newly written data may at least include updated target index data.
  • the modification information may include newly added data files and/or deleted data files; wherein, the newly written data determination module 620 is used for:
  • the modification information includes a newly added data file
  • the updated target index data is obtained, and the newly added data file and the updated target index data are determined as newly written data
  • the modification information includes the identifier of the deleted data file
  • the updated target index data is obtained, and the updated target index data is determined as newly written data.
  • the target index data may include first index data and second index data
  • the first index data may include index data of each data file in the at least one data file
  • the second index data may include the first index data.
  • Index data of index data wherein, the newly written data determination module 620 is used for:
  • the updated first index data and the updated second index data are determined as the updated target index data.
  • the newly written data determination module 620 is used to:
  • the index data of the newly added data file is added to the first index data to obtain the updated first index data;
  • the index data corresponding to the identifier of the deleted data file is deleted from the first index data to obtain the updated first index data.
  • the storage module 630 is used to:
  • the modification information may include the identification of the deleted data file
  • the storage module 630 is used for:
  • the file storage device 600 may further include a saving module for:
  • FIG. 7 is a schematic structural diagram of an embodiment of a file storage device provided according to the present application.
  • the file storage device 700 may include a processor 701 and a memory 702 storing computer program instructions.
  • processor 701 may include a central processing unit (CPU), or a specific integrated circuit (Application Specific Integrated Circuit, ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
  • CPU central processing unit
  • ASIC Application Specific Integrated Circuit
  • Memory 702 may include mass storage for data or instructions.
  • memory 702 may include a Hard Disk Drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a Universal Serial Bus (USB) drive or two or more A combination of more than one of the above.
  • Memory 702 may include removable or non-removable (or fixed) media, where appropriate.
  • Memory 702 may be internal or external to file storage device 700, where appropriate.
  • memory 702 is non-volatile solid state memory.
  • memory 702 may include read only memory (ROM).
  • ROM read only memory
  • the ROM may be a mask programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), electrically rewritable ROM (EAROM) or flash memory or A combination of two or more of the above.
  • Memory may include read only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical/tangible memory storage devices.
  • ROM read only memory
  • RAM random access memory
  • magnetic disk storage media devices e.g., magnetic disks
  • optical storage media devices e.g., magnetic disks
  • flash memory devices e.g., electrical, optical or other physical/tangible memory storage devices.
  • a memory includes one or more tangible (non-transitory) computer-readable storage media (eg, memory devices) encoded with software including computer-executable instructions, and when the software is executed (eg, by a or multiple processors), it is operable to perform the operations described with reference to the method of file storage according to the present application.
  • the processor 701 reads and executes the computer program instructions stored in the memory 702 to implement any one of the file storage methods in the foregoing embodiments.
  • the file storage device may also include a communication interface 703 and a bus 710 .
  • the processor 701 , the memory 702 , and the communication interface 703 are connected through the bus 710 and complete the mutual communication.
  • the communication interface 703 is mainly used to implement communication between modules, apparatuses, units and/or devices in the embodiments of the present application.
  • the bus 710 may include hardware, software, or both, coupling the components of the file storage device to each other.
  • the bus may include Accelerated Graphics Port (AGP) or other graphics bus, Enhanced Industry Standard Architecture (EISA) bus, Front Side Bus (FSB), HyperTransport (HT) Interconnect, Industry Standard Architecture (ISA) Bus, Infiniband Interconnect, Low Pin Count (LPC) Bus, Memory Bus, Microchannel Architecture (MCA) Bus, Peripheral Component Interconnect (PCI) Bus, PCI-Express (PCI-X) Bus, Serial Advanced Technology Attachment (SATA) bus, Video Electronics Standards Association Local (VLB) bus or other suitable bus or a combination of two or more of the above.
  • Bus 710 may include one or more buses, where appropriate. Although embodiments of this application describe and illustrate a particular bus, this application contemplates any suitable bus or interconnect.
  • the embodiment of the present application may provide a computer storage medium for implementation.
  • Computer program instructions are stored on the computer storage medium; when the computer program instructions are executed by the processor, any one of the file storage methods in the foregoing embodiments is implemented.
  • Examples of computer storage media include non-transitory computer storage media such as electronic circuits, semiconductor memory devices, ROM, random access memory, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks.
  • the functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof.
  • it When implemented in hardware, it may be, for example, an electronic circuit, an application specific integrated circuit (ASIC), suitable firmware, a plug-in, a function card, or the like.
  • ASIC application specific integrated circuit
  • elements of the present application are programs or code segments used to perform the required tasks.
  • the program or code segments may be stored in a machine-readable medium or transmitted over a transmission medium or communication link by a data signal carried in a carrier wave.
  • a "machine-readable medium” may include any medium that can store or transmit information.
  • machine-readable media examples include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, and the like.
  • the code segments may be downloaded via a computer network such as the Internet, an intranet, or the like.
  • processors may be, but are not limited to, general purpose processors, special purpose processors, application specific processors, or field programmable logic circuits. It will also be understood that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can also be implemented by special purpose hardware for performing the specified functions or actions, or by special purpose hardware and/or A combination of computer instructions is implemented.

Abstract

A file storage method and apparatus, a device, and a medium. The method comprises: in response to a storage request for a target file, acquiring information of modification to an original file, wherein the target file is a file obtained by modifying the original file, and a storage file of the original file comprises at least one data file and target index data corresponding to the at least one data file (310); determining newly-written data on the basis of the modification information, wherein the newly-written data at least comprises updated target index data (320); and replacing the target index data with the newly-written data, so as to obtain a storage file of the target file (330). The method can improve the storage efficiency of a target file.

Description

文件存储方法、装置、设备和介质File storage method, apparatus, device and medium
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求享有于2020年08月19日提交的名称为“文件存储方法、装置、设备和介质”的中国专利申请202010836266.5的优先权,该申请的全部内容通过引用并入本文中。This application claims the priority of Chinese Patent Application No. 202010836266.5 filed on Aug. 19, 2020, entitled "File Storage Method, Apparatus, Device and Medium", the entire content of which is incorporated herein by reference.
技术领域technical field
本申请涉及数据处理领域,尤其涉及一种文件存储方法、装置、设备和介质。The present application relates to the field of data processing, and in particular, to a file storage method, apparatus, device and medium.
背景技术Background technique
目前,用户制作完多媒体文件(例如课件)进行保存时,一般是将多媒体文件的数据和各类资源打包为一个压缩文件存储在磁盘上。例如,多媒体文件为课件时,若用户修改了课件的部分内容需要再次保存时,则需要将最新的数据文件和各类资源重新打包生成新的压缩文件。当课件包含的资源较多较大时,生成的压缩文件也很大,每次保存修改后的文件都需要消耗很长时间。At present, when a user finishes making a multimedia file (eg, courseware) and saves it, the data and various resources of the multimedia file are generally packaged into a compressed file and stored on a disk. For example, when the multimedia file is courseware, if the user modifies part of the courseware and needs to save it again, the latest data file and various resources need to be repackaged to generate a new compressed file. When the courseware contains a lot of resources, the compressed file generated is also very large, and it takes a long time to save the modified file each time.
用户修改课件时,一般只是修改课件中的一小部分内容,但是保存修改后的课件时却重新保存了所有的文件内容,导致文件存储效率较低。When users modify courseware, they generally only modify a small part of the content in the courseware, but when saving the modified courseware, all the file contents are re-saved, resulting in low file storage efficiency.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种文件存储方法、装置、设备及计算机存储介质,能够解决文件存储效率较低的问题。The present application provides a file storage method, device, device and computer storage medium, which can solve the problem of low file storage efficiency.
第一方面,本申请提供了一种文件存储方法,方法可以包括:In a first aspect, the present application provides a file storage method, which may include:
响应于针对目标文件的存储请求,获取对原始文件的修改信息,其中,目标文件是对原始文件修改后的文件,原始文件的存储文件可以包括至少一个数据文件和至少一个数据文件对应的目标索引数据;In response to the storage request for the target file, the modification information of the original file is obtained, wherein the target file is a modified file of the original file, and the storage file of the original file may include at least one data file and the target index corresponding to the at least one data file data;
基于修改信息确定新写入数据,新写入数据至少可以包括更新后的目标索引数据;Determine the newly written data based on the modification information, and the newly written data may at least include the updated target index data;
将目标索引数据替换为新写入数据,得到目标文件的存储文件。Replace the target index data with the newly written data to obtain the storage file of the target file.
第二方面,本申请提供了一种文件存储装置,装置可以包括:In a second aspect, the present application provides a file storage device, the device may include:
修改信息获取模块,用于响应于针对目标文件的存储请求,获取对原始文件的修改信息,其中,目标文件是对原始文件修改后的文件,原始文件的存储文件可以包括至少一个数据文件和至少一个数据文件对应的目标索引数据;The modification information obtaining module is used to obtain modification information of the original file in response to the storage request for the target file, wherein the target file is a modified file of the original file, and the storage file of the original file may include at least one data file and at least one data file. The target index data corresponding to a data file;
新写入数据确定模块,用于基于修改信息确定新写入数据,新写入数据至少可以包括更新后的目标索引数据;a newly written data determination module, configured to determine newly written data based on the modification information, and the newly written data may at least include updated target index data;
存储模块,用于将目标索引数据替换为新写入数据,得到目标文件的存储文件。The storage module is used to replace the target index data with newly written data to obtain the storage file of the target file.
第三方面,本申请提供了一种文件存储设备,设备可以包括:处理器以及存储有计算机程序指令的存储器;In a third aspect, the present application provides a file storage device, the device may include: a processor and a memory storing computer program instructions;
处理器执行计算机程序指令时可以实现如上述第一方面提供的文件存储方法。When the processor executes the computer program instructions, the file storage method provided in the first aspect can be implemented.
第四方面,本申请提供了一种计算机存储介质,计算机存储介质上存储有计算机程序指令,计算机程序指令被处理器执行时可以实现如上述第一方面提供的文件存储方法。In a fourth aspect, the present application provides a computer storage medium, where computer program instructions are stored thereon, and when the computer program instructions are executed by a processor, the file storage method provided in the first aspect can be implemented.
本申请提供的文件存储方法、装置、设备及计算机存储介质,在保存修改后的目标文件时,基于对原始文件的修改信息可以确定新写入数据。其中,新写入数据至少可以包括更新后的目标索引数据。在对目标文件进行存储时,只需要将原始文件的存储文件中的目标索引数据替换为新写入数据,即可以实现对目标文件的存储,即使用增量方式保存了目标文件,减少了需要重新保存的数据量,提高了对修改后的文件的存储效率。In the file storage method, device, device and computer storage medium provided by the present application, when the modified target file is saved, newly written data can be determined based on the modification information of the original file. The newly written data may at least include updated target index data. When storing the target file, it is only necessary to replace the target index data in the storage file of the original file with the newly written data, so that the target file can be stored, that is, the target file is saved in an incremental manner, reducing the need for The amount of data to be re-saved improves the storage efficiency of modified files.
附图说明Description of drawings
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例中所需要使用的附图作简单地介绍,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions of the embodiments of the present application more clearly, the following briefly introduces the accompanying drawings that need to be used in the embodiments of the present application. For those of ordinary skill in the art, without creative work, the Additional drawings can be obtained from these drawings.
图1是根据本申请提供的课件的结构示意图;Fig. 1 is the structural representation of the courseware provided according to the application;
图2是根据本申请提供的原始课件的存储文件的结构示意图;Fig. 2 is the structural representation of the storage file of the original courseware provided according to the application;
图3是根据本申请提供的文件存储方法的一个实施例的流程示意图;3 is a schematic flowchart of an embodiment of a file storage method provided according to the present application;
图4是根据本申请提供的目标文件的存储文件的一个实施例的结构示意图;4 is a schematic structural diagram of an embodiment of a storage file of a target file provided according to the present application;
图5是根据本申请提供的目标文件的存储文件的另一个实施例的结构示意图;5 is a schematic structural diagram of another embodiment of a storage file of a target file provided according to the present application;
图6是根据本申请提供的文件存储装置的一个实施例的结构示意图;6 is a schematic structural diagram of an embodiment of a file storage device provided according to the present application;
图7是根据本申请提供的文件存储设备的一个实施例的结构示意图。FIG. 7 is a schematic structural diagram of an embodiment of a file storage device provided according to the present application.
具体实施方式detailed description
下面将详细描述本申请的各个方面的特征和示例性实施例,为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细描述。应理解,此处所描述的具体实施例仅被配置为解释本申请,并不被配置为限定本申请。对于本领域技术人员来说,本申请可以在不需要这些具体细节中的一些细节的情况下实施。下面对实施例的描述仅仅是为了通过示出本申请的示例来提供对本申请更好的理解。The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present application, and are not configured to limit the present application. It will be apparent to those skilled in the art that the present application may be practiced without some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present application by illustrating examples of the present application.
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any relationship between these entities or operations. any such actual relationship or sequence exists. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion such that a process, method, article or device comprising a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element defined by the phrase "comprises" does not preclude the presence of additional identical elements in a process, method, article, or device that includes the element.
多媒体文件可以为PPT(PowerPoint)文件。PPT软件是一种演示文稿图形软件,主要用于制作幻灯片。该软件能够创建生动的视觉效果并支持多媒体功能。例如,在会议室场景下,会议主讲人可以利用PPT软件制作的会议文件向参会人员进行展示主讲内容。在教学场景下,教师可以利用PPT软件制作的课件进行授课。课件例如可以是根据教学大纲的要求,经过教学目标确定,教学内容和任务分析,教学活动结构及界面设计等环节,而加以制作的课程软件。The multimedia file may be a PPT (PowerPoint) file. PPT software is a presentation graphics software, mainly used for making slides. The software is capable of creating vivid visual effects and supports multimedia functions. For example, in a conference room scenario, the speaker of the conference can use the conference file made by the PPT software to present the lecture content to the participants. In the teaching scenario, teachers can use the courseware made by PPT software to teach. For example, the courseware can be course software produced according to the requirements of the teaching syllabus, through the determination of teaching objectives, the analysis of teaching content and tasks, the structure of teaching activities and the design of interface.
下面以课件为例对PPT类的多媒体文件的存储格式进行介绍。图1是本申请提供的课件的结构示意图。如图1所示,课件一般由“主数据文件、页面数据文件、资源数据文件”这三类数据文件组成。其中,主数据文件和页面数据文件的数据格式例如均为可扩展标记语言(Extensible Markup Language,XML)格式。例如,主数据文件可以包括课件的整体样式数据、页面总数等信息。例如,页面数据文件可以包括当前页面的页面布局数据以及文字数据等数据。资源数据文件可以包括课件页面中的图片、音频、视频等文件。The following takes courseware as an example to introduce the storage format of multimedia files such as PPT. FIG. 1 is a schematic structural diagram of the courseware provided by this application. As shown in Figure 1, the courseware generally consists of three types of data files: "main data file, page data file, and resource data file". The data formats of the main data file and the page data file are, for example, Extensible Markup Language (Extensible Markup Language, XML) format. For example, the master data file may include the overall style data of the courseware, the total number of pages, and so on. For example, the page data file may include page layout data and text data of the current page and other data. The resource data file may include pictures, audio, video and other files in the courseware page.
其中,对于一个课件,主数据文件只有一个。页面数据文件对应一个课件的页面,即页面数据文件的个数和课件的页数对应。资源数据文件的个数与课件中各个页面使用的图片、音频、视频等资源的个数相关。当需要将课件保存为磁盘文件时,需要将这些数据文件打包为一个压缩包文件,形成最终的课件文件,即该课件在磁盘上的存储文件。Among them, for a courseware, there is only one master data file. The page data file corresponds to a page of a courseware, that is, the number of page data files corresponds to the number of pages of the courseware. The number of resource data files is related to the number of pictures, audio, video and other resources used by each page in the courseware. When the courseware needs to be saved as disk files, these data files need to be packaged into a compressed package file to form the final courseware file, that is, the storage file of the courseware on the disk.
课件文件一般使用ZIP格式。ZIP文件格式是一种数据压缩和文档储存的文件格式。如图2所示,一个ZIP文件主要由三个部分组成,文件数据存储区、中央目录结构区和中央目录结束区。Courseware files generally use ZIP format. The ZIP file format is a file format for data compression and document storage. As shown in Figure 2, a ZIP file is mainly composed of three parts, the file data storage area, the central directory structure area and the central directory end area.
文件数据存储区用于保存课件中各个数据文件的概要信息和文件内容。参见图2,文件数据存储区包括n个数据文件:数据文件1、数据文件2、……、数据文件n。n为正整数。The file data storage area is used to save the general information and file content of each data file in the courseware. Referring to Fig. 2, the file data storage area includes n data files: data file 1, data file 2, ..., data file n. n is a positive integer.
中央目录结构区用于保存课件中每个数据文件的索引数据。其中,每个数据文件的索引数据可以包括该数据文件的摘要信息以及该数据文件相对于ZIP文件中的首地址的偏移地址以及该数据文件的文件长度等信息。The central directory structure area is used to save the index data of each data file in the courseware. The index data of each data file may include the summary information of the data file, the offset address of the data file relative to the first address in the ZIP file, and the file length of the data file and other information.
中央目录结束区用于保存中央目录结构区中每个数据文件的索引数据的索引数据。例如,中央目录结束区用于保存中央目录结构区中索引数据的个数(即中央目录数n),以及每个数据文件的索引数据相对于ZIP文件中的首地址的偏移地址(即中央目录偏移)以及中央目标结构区中数据的总长度(即中央目录长度)等信息。ZIP文件的绝大部分数据都位于“文件数据存储区”,只有小部分数据位于“中央目录结构区”和“中央目录结束区”。The central directory end area is used to save the index data of the index data of each data file in the central directory structure area. For example, the central directory end area is used to save the number of index data in the central directory structure area (ie the number of central directories n), and the offset address of the index data of each data file relative to the first address in the ZIP file (ie the central directory number n) directory offset) and the total length of the data in the central target structure area (ie, the central directory length). Most of the data of the ZIP file is located in the "file data storage area", and only a small part of the data is located in the "central directory structure area" and "central directory end area".
但是,当用户修改了课件的部分内容需要再次保存时,需要将最新的数据文件和各类资源重新打包生成新的压缩文件。当课件包含的数据文件和资源较多较大时,生成的压缩文件也很大,每次保存修改后的文件都需要消耗很长时间,导致文件存储效率较低。However, when the user modifies part of the content of the courseware and needs to save it again, the latest data files and various resources need to be repackaged to generate new compressed files. When the courseware contains many data files and resources, the generated compressed files are also large, and it takes a long time to save the modified files each time, resulting in low file storage efficiency.
基于此,本申请提供一种文件存储方法,可以提高对修改后的文件的存储效率。下面结合具体实施例和附图对本申请提供的文件存储方法进行详细介绍。Based on this, the present application provides a file storage method, which can improve the storage efficiency of modified files. The file storage method provided by the present application will be described in detail below with reference to specific embodiments and accompanying drawings.
图3是本申请提供的文件存储方法的一实施例的流程示意图。如图3所示,本申请 提供的文件存储方法300可以包括:FIG. 3 is a schematic flowchart of an embodiment of a file storage method provided by the present application. As shown in Figure 3, the file storage method 300 provided by the present application may include:
步骤310,响应于针对目标文件的存储请求,获取对原始文件的修改信息,其中,目标文件是对原始文件修改后的文件,原始文件的存储文件可以包括至少一个数据文件和至少一个数据文件对应的目标索引数据; Step 310, in response to the storage request for the target file, obtain the modification information of the original file, wherein, the target file is the modified file of the original file, and the storage file of the original file may include at least one data file corresponding to at least one data file. the target index data;
步骤320,基于修改信息确定新写入数据,新写入数据至少可以包括更新后的目标索引数据; Step 320, determining newly written data based on the modification information, and the newly written data may at least include updated target index data;
步骤330,将目标索引数据替换为新写入数据,得到目标文件的存储文件。Step 330: Replace the target index data with newly written data to obtain a storage file of the target file.
下面分别对步骤310~步骤330中每个步骤的具体实现方式进行详细介绍。The specific implementation of each step in steps 310 to 330 will be introduced in detail below.
首先,介绍步骤310的具体实现方式。First, the specific implementation of step 310 is introduced.
在本申请的实施例中,原始文件可以为PPT文件。PPT文件例如可以包括课件、会议文件等文件。在对原始文件使用的过程中,可能需要对原始文件进行修改。目标文件则为对原始文件修改后的文件。In the embodiment of the present application, the original file may be a PPT file. The PPT file may include, for example, courseware, conference files, and other files. During use of the original file, modifications to the original file may be required. The target file is the modified file from the original file.
下面以原始文件为原始课件为例,来介绍对原始文件的修改的几种情况:The following takes the original file as the original courseware as an example to introduce several situations of modifying the original file:
情况一:修改原始课件中已有页面的内容。Case 1: Modify the content of the existing page in the original courseware.
在本申请的实施例中,修改原始课件中已有页面的内容可以包括:向原始课件中的已有页面增加新数据、删除原始课件中已有页面中的已有数据、修改原始课件中已有页面的数据等情况。其中,修改原始课件中已有页面的数据可以转换为对该页面中已有数据的删除和向该页面中增加新数据。In the embodiment of the present application, modifying the content of the existing pages in the original courseware may include: adding new data to the existing pages in the original courseware, deleting existing data in the existing pages in the original courseware, modifying the existing pages in the original courseware There are page data and so on. Among them, modifying the data of the existing page in the original courseware can be converted into deleting the existing data in the page and adding new data to the page.
因此,对原始课件中已有页面的内容的修改可以表现为对已有页面的原始页面数据文件的删除以及对修改后的已有页面的新页面数据文件的新增。Therefore, the modification to the content of the existing page in the original courseware can be expressed as the deletion of the original page data file of the existing page and the addition of the new page data file of the modified existing page.
也就是说,在情况一的场景下,对原始文件的修改信息可以包括新增的修改后的已有页面的新页面数据文件以及删除的已有页面的原始页面数据文件的标识。That is to say, in the scenario of Case 1, the modification information to the original file may include the identifiers of the new page data file of the newly added modified existing page and the original page data file of the deleted existing page.
情况二:向原始课件中增加新的页面。Case 2: Add a new page to the original courseware.
在本申请的实施例中,向原始课件中增加新的页面可以表现为对该新增页面的页面数据文件的新增以及该新增页面对应的资源数据文件的新增。需要说明的是,若向原始课件中新增了新的页面,则主数据文件也会发生更新(新增该页面的记录)。因此,向原始课件中增加新的页面还表现为对原始课件的原始主数据文件的删除以及对更新后的主数据文件的新增。In the embodiment of the present application, adding a new page to the original courseware can be represented as adding a page data file of the new page and adding a resource data file corresponding to the new page. It should be noted that if a new page is added to the original courseware, the master data file will also be updated (the record of this page is added). Therefore, adding new pages to the original courseware also manifests as deletion of the original master data file of the original courseware and addition of the updated master data file.
也就是说,在情况二的场景下,对原始文件的修改信息可以包括新增的新增页面的页面数据文件、新增的新增页面对应的资源数据文件、删除的原始课件的原始主数据文件的标识以及新增的更新后的主数据文件。That is to say, in the scenario of case 2, the modification information to the original file may include the page data file of the newly added new page, the resource data file corresponding to the newly added new page, and the original master data of the deleted original courseware The identification of the file and the new updated master data file.
情况三:删除原始课件中的页面。Case 3: Delete the page in the original courseware.
在本申请的实施例中,删除原始课件中的页面可以表现为删除该页面的原始页面数据文件以及该页面对应的原始资源数据文件。需要说明的是,若删除了原始课件中的页面,则主数据文件也会发生更新(删除该页面的记录)。因此,删除原始课件中的页面还表现为对原始课件的原始主数据文件的删除以及对更新后的主数据文件的新增。In the embodiment of the present application, deleting a page in the original courseware may be expressed as deleting the original page data file of the page and the original resource data file corresponding to the page. It should be noted that if the page in the original courseware is deleted, the master data file will also be updated (delete the record of the page). Therefore, the deletion of the pages in the original courseware also manifests as deletion of the original master data file of the original courseware and addition of the updated master data file.
也就是说,在情况三的场景下,对原始文件的修改信息可以包括删除的页面的原始页面数据文件的标识、删除的页面对应的原始资源数据文件的标识、删除的原始课件的原始主数据文件的标识以及新增的更新后的主数据文件。That is to say, in the scenario of Scenario 3, the modification information to the original file may include the identifier of the original page data file of the deleted page, the identifier of the original resource data file corresponding to the deleted page, and the original master data of the deleted original courseware The identification of the file and the new updated master data file.
在本申请的实施例中,对原始课件的修改,例如是对该课件中页面内的元素进行增加、删除或修改,或者进行页面的增加或删除,这些修改操作最终反映为对主数据文件、页面数据文件、资源数据文件这三类数据文件的增加、删除或修改。这三类数据文件是课件保存到磁盘时的存储粒度。而对数据文件的修改又可以转换为对已有数据文件的删除,以及对新的数据文件的增加。因此,对原始文件的修改可以包括对原始文件中已有数据文件的删除以及对新的数据文件的增加。如此,对原始文件的修改信息可以包括新增的数据文件和删除的数据文件的标识。In the embodiment of this application, the modification of the original courseware, for example, is to add, delete or modify elements in the page in the courseware, or to add or delete pages, these modification operations are finally reflected as changes to the main data file, The addition, deletion or modification of three types of data files: page data files and resource data files. These three types of data files are the storage granularity when courseware is saved to disk. The modification of data files can be converted into deletion of existing data files and addition of new data files. Therefore, modifications to the original file may include deletion of existing data files in the original file and addition of new data files. In this way, the modification information to the original file may include identifiers of newly added data files and deleted data files.
若用户想要保存修改后的原始文件,即用户想要保存目标文件,则用户可以通过原始文件所在设备发送对目标文件的存储请求。原始文件所在设备响应于针对目标文件的存储请求,可以获取存储请求的获取时间。通过获取存储请求的获取时间以及原始文件的保存时间,可以得到在存储请求的获取时间以及原始文件的保存时间之间对原始文件的所有操作记录。根据对原始文件的所有操作记录,可以统计出对原始文件修改后,哪些数据文件发生了变化。通过对比原始文件修改前和修改后的数据文件清单,则可以得到新增的数据文件以及删除的数据文件的标识,则可以得到对原始文件的修改信息。If the user wants to save the modified original file, that is, the user wants to save the target file, the user can send a storage request for the target file through the device where the original file is located. In response to the storage request for the target file, the device where the original file is located may obtain the acquisition time of the storage request. By acquiring the acquisition time of the storage request and the preservation time of the original file, all operation records of the original file between the acquisition time of the storage request and the preservation time of the original file can be obtained. According to all operation records of the original file, it can be counted which data files have changed after the original file has been modified. By comparing the list of data files before and after the modification of the original file, the identifiers of the newly added data file and the deleted data file can be obtained, and then the modification information of the original file can be obtained.
在本申请的实施例中,原始文件的存储文件可以是原始文件被存储至磁盘时对应的最终文件。参见图2,原始文件的存储文件可以包括至少一个数据文件以及至少一个 数据文件对应的目标索引数据。其中,至少一个数据文件可以包括原始文件中的主数据文件、页面数据文件和资源数据文件。至少一个数据文件对应的目标索引数据可以包括第一索引数据和第二索引数据。其中,第一索引数据可以包括图2中所示的中央目标结构区所存储的至少一个数据文件中每个数据文件的索引数据。第二索引数据可以包括第一索引数据的索引数据,即图2中所示的中央目录结束区中的数据。In the embodiment of the present application, the storage file of the original file may be the final file corresponding to when the original file is stored to the disk. Referring to Fig. 2, the storage file of the original file may include at least one data file and target index data corresponding to the at least one data file. Wherein, at least one data file may include a main data file, a page data file and a resource data file in the original file. The target index data corresponding to at least one data file may include first index data and second index data. The first index data may include index data of each data file in the at least one data file stored in the central target structure area shown in FIG. 2 . The second index data may include index data of the first index data, that is, data in the end area of the central directory shown in FIG. 2 .
下面介绍步骤320的具体实现方式。The specific implementation manner of step 320 is described below.
在本申请的实施例中,对原始文件的修改信息可以包括新增的数据文件和/或删除的数据文件的标识。无论修改信息中包括新增的数据文件还是包括删除的数据文件的标识,目标索引数据均需要基于对原始文件的修改信息进行更新。因此,新写入数据至少可以包括更新后的目标索引数据。其中,更新后的目标索引数据例如是基于对原始文件的修改信息进行更新的。In the embodiment of the present application, the modification information to the original file may include an identifier of a newly added data file and/or a deleted data file. Regardless of whether the modification information includes an identifier of a newly added data file or an identifier of a deleted data file, the target index data needs to be updated based on the modification information of the original file. Therefore, the newly written data may include at least the updated target index data. The updated target index data is, for example, updated based on the modification information of the original file.
若要实现将目标文件存储至磁盘,新增的数据文件需要进行保存。但是为了提高对目标文件的存储效率,删除的数据文件不一定需要真实删除。在本申请的实施例中,可以基于需要删除的数据文件的标识更新目标索引数据,并将更新后的目标索引数据作为新写入数据,也可以实现对目标文件的存储。To save the target file to disk, the newly added data file needs to be saved. However, in order to improve the storage efficiency of target files, deleted data files do not necessarily need to be actually deleted. In the embodiment of the present application, the target index data may be updated based on the identifier of the data file to be deleted, and the updated target index data may be used as newly written data, and the storage of the target file may also be implemented.
因此,在本申请的一些实施例中,步骤320可以包括步骤3201和步骤3202。Therefore, in some embodiments of the present application, step 320 may include step 3201 and step 3202 .
步骤3201,在修改信息包括新增的数据文件的情况下,基于修改信息得到更新后的目标索引数据,并将新增的数据文件和更新后的目标索引数据,确定为新写入数据;Step 3201, in the case that the modification information includes the newly added data file, obtain the updated target index data based on the modification information, and determine the newly added data file and the updated target index data as newly written data;
步骤3202,在修改信息包括删除的数据文件的标识的情况下,基于修改信息得到更新后的目标索引数据,并将更新后的目标索引数据,确定为新写入数据。Step 3202, in the case that the modification information includes the identifier of the deleted data file, obtain the updated target index data based on the modification information, and determine the updated target index data as newly written data.
在本申请的实施例中,若对原始文件的修改信息包括新增的数据文件,则需要在文件数据存储区后面写入新增的数据文件。若在文件数据存储区后面写入新增的数据文件,则中央目录结构区中的第一索引数据需要增加新增的数据文件的索引数据。由于中央目录结构区的第一索引数据中增添了新的索引数据,则中央目录结束区中的第二索引数据也需要对应进行更新,即目标索引数据需要基于新增的数据文件进行更新。因此,新写入数据包括新增的数据文件和更新后的目标索引数据。In the embodiment of the present application, if the modification information to the original file includes a newly added data file, the newly added data file needs to be written after the file data storage area. If the newly added data file is written after the file data storage area, the index data of the newly added data file needs to be added to the first index data in the central directory structure area. Since new index data is added to the first index data in the central directory structure area, the second index data in the central directory end area also needs to be updated accordingly, that is, the target index data needs to be updated based on the newly added data file. Therefore, the newly written data includes newly added data files and updated target index data.
但是,若原始文件的修改信息包括删除的数据文件的标识,为了节省对目标文件的保存时间,可以不需要删除文件数据存储区中该标识对应的数据文件,可以只更新目标索引数据。例如,可以从中央目录结构区的第一索引数据中去除需要删除的数据 文件的索引数据。由于中央目录结构区的第一索引数据删除了部分索引数据,则中央目录结束区中的第二索引数据也需要随之对应更新。也就是说,目标索引数据需要基于删除的数据文件的标识进行更新,从而实现对需要删除的数据文件进行索引数据的删除,即标记删除。However, if the modification information of the original file includes the identifier of the deleted data file, in order to save the storage time of the target file, it is not necessary to delete the data file corresponding to the identifier in the file data storage area, and only the target index data can be updated. For example, the index data of the data files to be deleted may be removed from the first index data of the central directory structure area. Since part of the index data is deleted from the first index data in the central directory structure area, the second index data in the central directory end area also needs to be updated accordingly. That is to say, the target index data needs to be updated based on the identifier of the deleted data file, so as to realize the deletion of the index data of the data file to be deleted, that is, mark deletion.
下面介绍基于对原始文件的修改信息得到更新后的目标索引数据。在本申请的实施例中,目标索引数据可以包括第一索引数据和第二索引数据,第一索引数据可以包括至少一个数据文件中每个数据文件的索引数据,第二索引数据可以包括第一索引数据的索引数据。The following describes the updated target index data obtained based on the modification information of the original file. In the embodiment of the present application, the target index data may include first index data and second index data, the first index data may include index data of each data file in the at least one data file, and the second index data may include the first index data Index data for index data.
其中,在步骤3201和步骤3202中,基于修改的数据文件,得到更新后的目标索引数据可以包括:步骤A~步骤C。步骤A,基于修改信息更新第一索引数据,得到更新后的第一索引数据;步骤B,根据更新后的第一索引数据,更新第二索引数据,得到更新后的第二索引数据;步骤C,将更新后的第一索引数据和更新后的第二索引数据确定为更新后的目标索引数据。Wherein, in step 3201 and step 3202, based on the modified data file, obtaining the updated target index data may include steps A to C. Step A, update the first index data based on the modification information, and obtain the updated first index data; Step B, update the second index data according to the updated first index data, and obtain the updated second index data; Step C , and determine the updated first index data and the updated second index data as the updated target index data.
在步骤A中,在修改的数据文件包括新增的数据文件的情况下,在第一索引数据中增加新增的数据文件的索引数据,得到更新后的第一索引数据。In step A, if the modified data file includes the newly added data file, the index data of the newly added data file is added to the first index data to obtain the updated first index data.
在步骤A中,在修改的数据文件包括删除的数据文件的标识情况下,从第一索引数据中删除该标识对应的删除的数据文件的索引数据,得到更新后的第一索引数据。In step A, when the modified data file includes the identifier of the deleted data file, the index data of the deleted data file corresponding to the identifier is deleted from the first index data to obtain the updated first index data.
在步骤A中,在修改的数据文件包括新增的数据文件和删除的数据文件的情况下,从第一索引数据中增加新增的数据文件的索引数据以及从第一索引数据中删除该标识对应的删除的数据文件的索引数据,得到更新后的第一索引数据。In step A, in the case that the modified data file includes a newly added data file and a deleted data file, the index data of the newly added data file is added from the first index data and the identifier is deleted from the first index data The index data of the corresponding deleted data file is obtained to obtain the updated first index data.
由于中央目录结束区中存储的第二索引数据包括中央目录结构区中第一索引数据的索引数据,例如,中央目录结束区用于保存中央目录结构区中索引数据的个数,以及每个数据文件的索引数据相对于ZIP文件中的首地址的偏移地址以及中央目录结构区中索引数据的总数据长度等信息,所以在步骤B中,若第一索引数据中出现数据文件的索引数据的增加或删除,则第二索引数据需要随着第一索引数据的更新进行更新。Since the second index data stored in the central directory end area includes the index data of the first index data in the central directory structure area, for example, the central directory end area is used to store the number of index data in the central directory structure area, and each data The index data of the file is relative to the offset address of the first address in the ZIP file and the total data length of the index data in the central directory structure area. Therefore, in step B, if the index data of the data file appears in the first index data. addition or deletion, the second index data needs to be updated along with the update of the first index data.
例如,若更新后的第一索引数据包括新增的数据文件的索引数据,则中央目录结构区中索引数据的个数随之增加、每个数据文件的索引数据相对于ZIP文件中的首地址的偏移地址随之后移,以及第一索引数据的数据总长度随之增加,进而得到更新后的第二索引数据。For example, if the updated first index data includes the index data of the newly added data file, the number of index data in the central directory structure area increases accordingly, and the index data of each data file is relative to the first address in the ZIP file. The offset address of , then moves backward, and the total data length of the first index data increases accordingly, thereby obtaining the updated second index data.
在步骤C中,当对第一索引数据和第二索引数据均进行更新后,将更新后的第一索引数据和更新后的第二索引数据确定为更新后的目标索引数据。In step C, after both the first index data and the second index data are updated, the updated first index data and the updated second index data are determined as the updated target index data.
在本申请的一些实施例中,步骤330包括:在保持至少一个数据文件不变的情况下,将目标索引数据替换为新写入数据,得到目标文件的存储文件。In some embodiments of the present application, step 330 includes: under the condition of keeping at least one data file unchanged, replacing the target index data with newly written data to obtain a storage file of the target file.
在本申请的实施例中,对原始文件的修改,实际上就是对数据文件进行删除和新增。对于新增的数据文件,可以在原始文件的存储文件的文件内容后面进行追加。对于删除的数据文件,可以采用删除需要删除的数据文件的索引数据的方式进行处理,这样就可以复用原始文件的存储文件中的已有的数据文件,仅处理删除的数据文件和新增的数据文件。用户在修改课件时,通常只修改小部分内容,大多数内容是保持不变的,因此变化的数据要比不变的数据少很多,因此采用本申请提供的文件存储方法可以明显提升文件的保存速度。In the embodiment of the present application, the modification of the original file is actually the deletion and addition of the data file. For the newly added data file, it can be appended after the file content of the storage file of the original file. The deleted data files can be processed by deleting the index data of the data files to be deleted, so that the existing data files in the storage files of the original files can be reused, and only the deleted data files and newly added data files can be processed. data files. When users modify courseware, they usually only modify a small part of the content, and most of the content remains unchanged, so the changed data is much less than the unchanged data. Therefore, using the file storage method provided by this application can significantly improve the preservation of files. speed.
下面结合附图介绍在对原始文件的修改信息包括新增的数据文件的情况下,目标文件的存储文件的示意图。图4是本申请提供的目标文件的存储文件的示意图。如图4所示,点划线框内是原始文件的存储文件中所包括的至少一个数据文件。虚线框内是新写入数据。其中,在对原始文件的修改信息包括新增的数据文件的情况下,保持原始文件中的存储文件中的至少一个数据文件不变,然后在文件数据存储区结尾追加新写入数据即可。其中,新写入数据可以包括三部分内容:在文件数据存储区新增的数据文件、新的中央目录结构区中的更新后的第一索引数据以及新的中央目录结束区中的更新后的第二索引数据。The following describes a schematic diagram of a storage file of a target file in the case that the modification information to the original file includes a newly added data file with reference to the accompanying drawings. FIG. 4 is a schematic diagram of a storage file of a target file provided by the present application. As shown in FIG. 4 , within the dot-dash line frame is at least one data file included in the storage file of the original file. Inside the dashed box is the newly written data. Wherein, if the modification information to the original file includes a newly added data file, at least one data file in the storage files in the original file is kept unchanged, and then newly written data is added at the end of the file data storage area. Wherein, the newly written data may include three parts: the newly added data file in the file data storage area, the updated first index data in the new central directory structure area, and the updated first index data in the new central directory end area The second index data.
如图4所示,对原始文件的修改信息可以包括新增的数据文件n+1。更新后的第一索引数据可以包括目标索引数据中的第一索引数据以及新增的数据文件n+1的索引数据。也就是说,在原始文件的存储文件中的原有“中央目录结构区”基础上增加了新增的数据文件n+1的索引数据之后形成的新的“中央目录结构区”。并且,基于更新后的第一索引数据,将中央目录数更新为n+1,并更新了中央目录偏移和中央目录长度,得到更新后的第二索引数据。也就是说,在原始文件的存储文件中的原有“中央目录结束区”的基础上更新了中央目录数、中央目录偏移和中央目录长度,得到新的“中央目录结束区”。As shown in FIG. 4 , the modification information to the original file may include the newly added data file n+1. The updated first index data may include the first index data in the target index data and the index data of the newly added data file n+1. That is to say, a new "central directory structure area" is formed after adding the index data of the newly added data file n+1 to the original "central directory structure area" in the storage file of the original file. And, based on the updated first index data, the number of central directories is updated to n+1, and the central directory offset and the central directory length are updated to obtain updated second index data. That is, on the basis of the original "central directory end area" in the storage file of the original file, the number of central directories, the central directory offset and the central directory length are updated to obtain a new "central directory end area".
假设图2中示出的是原始文件的存储文件的示意图。图4所示的目标文件的存储文件,与图2中原始文件的存储文件相比,点划线框内的数据文件1~数据文件n保持不 变,然后在原始文件的存储文件的文件数据存储区之后增加图4中虚线框内的新写入数据。It is assumed that what is shown in FIG. 2 is a schematic diagram of the storage file of the original file. Compared with the storage file of the original file in FIG. 4, the storage file of the target file shown in FIG. 4, the data files 1 to n in the dotted line frame remain unchanged, and then the file data of the storage file of the original file is stored in the original file. After the storage area, the newly written data in the dotted box in FIG. 4 is added.
图4中目标文件的存储文件与图2中的原始的存储文件相比,新增了灰色区域所示的新增的数据文件n+1,以及数据文件n+1的索引数据。图4中目标文件的存储文件与图2中的原始的存储文件相比,修改了灰色区域中所示的中央目录偏移、中央目录长度和中央目录数。Compared with the original storage file in FIG. 2 , the storage file of the target file in FIG. 4 has newly added data file n+1 shown in the gray area, and the index data of the data file n+1. The storage file of the target file in FIG. 4 is compared with the original storage file in FIG. 2, and the central directory offset, the central directory length and the central directory number shown in the gray area are modified.
下面结合附图介绍在对原始文件的修改信息包括删除的数据文件的标识情况下,目标文件的存储文件的示意图。图5是本申请提供的目标文件的存储文件的示意图。如图5所示,点划线框内是原始文件的存储文件中所包括的至少一个数据文件。虚线框内是新写入数据。其中,在对原始文件的修改信息包括删除的数据文件的标识的情况下,保持原始文件中的存储文件中的至少一个数据文件不变,然后在文件数据存储区结尾追加新写入数据即可。其中,新写入数据可以包括两部分内容:新的中央目录结构区中的更新后的第一索引数据和新的中央目录结束区中的更新后的第二索引数据。In the following, a schematic diagram of the storage file of the target file in the case where the modification information to the original file includes the identifier of the deleted data file will be described with reference to the accompanying drawings. FIG. 5 is a schematic diagram of a storage file of a target file provided by the present application. As shown in FIG. 5 , within the dot-dash line frame is at least one data file included in the storage file of the original file. Inside the dashed box is the newly written data. Wherein, when the modification information to the original file includes the identifier of the deleted data file, keep at least one data file in the storage file in the original file unchanged, and then append the newly written data at the end of the file data storage area. . The newly written data may include two parts: the updated first index data in the new central directory structure area and the updated second index data in the new central directory end area.
如图5所示,对原始文件的修改信息可以包括删除的数据文件2的标识。更新后的第一索引数据可以包括从目标索引数据中的第一索引数据删除数据文件2的索引数据之后的数据。也就是说,在原始文件的存储文件中的原有“中央目录结构区”基础上删除了数据文件2的索引数据之后形成的新的“中央目录结构区”。并且,基于更新后的第一索引数据,将中央目录数更新为n-1,并更新了中央目录偏移和中央目录长度,得到更新后的第二索引数据。也就是说,在原始文件的存储文件中的原有“中央目录结束区”的基础上更新了中央目录数、中央目录偏移和中央目录长度,得到新的“中央目录结束区”。As shown in FIG. 5 , the modification information to the original file may include the identifier of the deleted data file 2 . The updated first index data may include data after the index data of the data file 2 is deleted from the first index data in the target index data. That is to say, a new "central directory structure area" is formed after deleting the index data of the data file 2 on the basis of the original "central directory structure area" in the storage file of the original file. And, based on the updated first index data, the number of central directories is updated to n-1, and the central directory offset and the central directory length are updated to obtain updated second index data. That is, on the basis of the original "central directory end area" in the storage file of the original file, the number of central directories, the central directory offset and the central directory length are updated to obtain a new "central directory end area".
图5所示的目标文件的存储文件,与图2中原始文件的存储文件相比,点划线框内的数据文件1~数据文件n保持不变,然后在原始文件的存储文件的文件数据存储区之后增加图5中虚线框内的新写入数据。Compared with the storage file of the original file in Fig. 5, the storage file of the target file shown in Fig. 5, the data file 1 to the data file n in the dotted line frame remain unchanged, and then the file data of the storage file of the original file After the storage area, the newly written data in the dotted box in FIG. 5 is added.
图5中目标文件的存储文件与图2中的原始的存储文件相比,删除了数据文件2的索引数据。图5中目标文件的存储文件与图2中的原始的存储文件相比,修改了灰色区域中所示的中央目录偏移、中央目录长度和中央目录数。Compared with the original storage file in FIG. 2 , the storage file of the target file in FIG. 5 has the index data of the data file 2 deleted. The storage file of the target file in FIG. 5 is compared with the original storage file in FIG. 2, and the central directory offset, the central directory length and the central directory number shown in the gray area are modified.
在本申请的实施例中,当获取对原始文件的修改信息后,则可以获取需要删除的数据文件列表以及需要增加的数据文件的列表。对于要删除的数据文件列表,只需要 从“中央目录结构区”中删除这些文件的索引数据,并修正“中央目录结束区”中的数据,然后使用新的“中央目录结构区”和“中央目录结束区”覆盖原有“中央目录结构区”和“中央目录结束区”即可,原有“文件数据存储区”的内容保持不变。In the embodiment of the present application, after the modification information on the original file is acquired, a list of data files to be deleted and a list of data files to be added can be acquired. For the list of data files to be deleted, it is only necessary to delete the index data of these files from the "Central Directory Structure Area" and correct the data in the "Central Directory End Area", and then use the new "Central Directory Structure Area" and "Central Directory Structure Area" The directory end area "overwrites the original "central directory structure area" and the "central directory end area", and the content of the original "file data storage area" remains unchanged.
对于要新增的数据文件列表,需要在原有“文件数据存储区”的尾部追加写入新增的数据文件,并在“中央目录结构区”追加新增的数据文件的索引数据(新的“文件数据存储区”变大了,原有“文件数据存储区”数据保持不动),同时修正“中央目录结束区”的数据,将新的“中央目录结构区”和“中央目录结束区”追加到新的“文件数据存储区”结尾即可。For the list of data files to be added, it is necessary to append the newly added data files to the end of the original "file data storage area", and append the index data of the newly added data files to the "central directory structure area" (the new " The file data storage area" has become larger, and the original "file data storage area" data remains unchanged), and the data of the "central directory end area" is revised, and the new "central directory structure area" and "central directory end area" Append to the end of the new "file datastore".
在本申请的实施例中,课件的绝大部分数据都保存在“文件数据存储区”,而对数据文件的删除和新增都直接复用了已有的“文件数据存储区”,只是修改了很少的数据,因此操作速度很快。In the embodiment of the present application, most of the data of the courseware is stored in the "file data storage area", and the deletion and addition of data files directly reuse the existing "file data storage area", only the modification Very little data is stored, so the operation is fast.
本申请提出的文件存储方法,在原始文件的存储文件的基础上使用增量方式保存目标文件,直接修改磁盘上的原始文件的存储文件,而不是在磁盘上生成文件副本进行操作,因此能够明显提升对目标文件的存储速度,且保存过程中不会过多占用磁盘空间。The file storage method proposed in the present application uses an incremental method to save the target file on the basis of the storage file of the original file, and directly modifies the storage file of the original file on the disk instead of generating a copy of the file on the disk for operation, so it can obviously Improve the storage speed of target files, and save too much disk space during the save process.
在本申请的实施例中,为了进一步减小目标文件的存储文件的大小,以减小保存目标文件至磁盘时所占用的磁盘空间,在修改信息包括删除的数据文件的标识的情况下,步骤330包括:在确定该标识对应的删除的数据文件的大小与原始文件的存储文件的大小的比值大于第一预设比值的情况下,从至少一个数据文件中删除该标识对应的删除的数据文件,并将目标索引数据替换为新写入数据,得到目标文件的存储文件。In the embodiment of the present application, in order to further reduce the size of the storage file of the target file, so as to reduce the disk space occupied when saving the target file to the disk, in the case where the modification information includes the identifier of the deleted data file, the step 330 includes: in the case of determining that the ratio of the size of the deleted data file corresponding to the identification to the size of the storage file of the original file is greater than the first preset ratio, deleting the deleted data file corresponding to the identification from at least one data file , and replace the target index data with the newly written data to obtain the storage file of the target file.
作为一个示例,第一预设比值可以为10%。As an example, the first preset ratio may be 10%.
也就是说,若对原始文件进行修改时,删除了较多的数据文件,那么若仍采用标记删除的方式进行保存目标文件,并没有实际删除“文件数据存储区”中需要删除的数据文件。因此,为了进一步减小目标文件的存储文件的大小,并减小目标文件保存至磁盘时所占用的空间,在删除的数据文件的大小与原始文件的存储文件的大小的比值大于第一预设比值的情况下,从至少一个数据文件中删除需要删除的数据文件,即对原始文件的存储文件中的数据进行真实删除,以减小课件文件的大小。That is to say, if a lot of data files are deleted when the original file is modified, then if the target file is still saved by mark deletion, the data files that need to be deleted in the "file data storage area" are not actually deleted. Therefore, in order to further reduce the size of the storage file of the target file and reduce the space occupied when the target file is saved to the disk, the ratio of the size of the deleted data file to the size of the storage file of the original file is greater than the first preset In the case of the ratio, the data files to be deleted are deleted from at least one data file, that is, the data in the storage file of the original file is actually deleted, so as to reduce the size of the courseware file.
在本申请的一些实施例中,为了避免原始文件的存储文件被损坏,在步骤310之前,本申请提供的文件存储方法还可以包括:将目标索引数据保存在内存中;和/或,将目标索引数据保存在磁盘中。In some embodiments of the present application, in order to prevent the storage file of the original file from being damaged, before step 310, the file storage method provided by the present application may further include: saving the target index data in the memory; and/or storing the target index data in the memory; Index data is kept on disk.
在目标文件的保存过程中用户选择取消保存的情况下,或者在目标文件的保存过程中计算机突然断电导致目标文件的保存被打断的情况下,会造成对原始文件的存储文件的损坏。因此为了避免原始文件的存储文件被损坏,可以对目标索引数据进行备份。When the user chooses to cancel saving during the saving of the target file, or when the computer is suddenly powered off during the saving of the target file and the saving of the target file is interrupted, the storage file of the original file will be damaged. Therefore, in order to prevent the storage file of the original file from being damaged, the target index data can be backed up.
在本申请的一些实施例中,在将目标文件保存至磁盘时,仅需要对原始文件的存储文件的“中央目录结构区”和“中央目录结束区”进行修改,不需要修改“文件数据存储区”。因此修改原始文件之前,如果对原有“中央目录结构区”和“中央目录结束区”进行备份,即对目标索引数据进行备份,当出现上述两种情况时,只需要向原始文件的存储文件中重新写入原有“中央目录结构区”和“中央目录结束区”数据,即只需要向原始文件的存储文件中重新写入目标索引数据,即可将原始文件恢复到修改前的状态,避免文件损坏的情况。In some embodiments of the present application, when saving the target file to the disk, only the "central directory structure area" and "central directory end area" of the storage file of the original file need to be modified, and the "file data storage area" does not need to be modified. Area". Therefore, before modifying the original file, if the original "central directory structure area" and "central directory end area" are backed up, that is, the target index data is backed up. When the above two situations occur, only the storage file of the original file needs to be Rewrite the original "central directory structure area" and "central directory end area" data in the original file, that is, you only need to rewrite the target index data into the storage file of the original file to restore the original file to the state before modification. Avoid file corruption situations.
在修改原始文件之前,可以通过以下两种方式中的至少一种方式对原始文件的存储文件中原有“中央目录结构区”和“中央目录结束区”进行备份,即对目标索引数据进行备份。第一种在内存中备份目标索引数据。第二种在磁盘上备份目标索引数据。在磁盘中目标索引数据时,可以在原始文件的存储文件所在目录进行备份,备份文件名可以为“原始文件的存储文件名.tmp”。如果对目标文件的保存正常完成,则删除目标索引数据的备份文件。Before modifying the original file, the original "central directory structure area" and "central directory end area" in the storage file of the original file can be backed up by at least one of the following two methods, that is, the target index data is backed up. The first backs up the target index data in memory. The second backs up the target index data on disk. When the target index data is stored in the disk, it can be backed up in the directory where the original file storage file is located, and the backup file name can be "original file storage file name.tmp". If saving of the target file is normally completed, the backup file of the target index data is deleted.
对于用户取消保存目标文件的情况,可以将原始文件的存储文件定位到原始“中央目录结构区”的起始位置,写入备份的原有“中央目录结构区”和“中央目录结束区”数据,即可恢复原始文件的存储文件,这种情况使用内存备份,文件恢复速度快。If the user cancels saving the target file, the storage file of the original file can be located at the starting position of the original "central directory structure area", and the data of the original "central directory structure area" and "central directory end area" of the backup can be written , you can restore the stored files of the original files. In this case, the memory backup is used, and the file recovery speed is fast.
对于出现异常断电导致的目标文件的保存被打断的情况,当用户再次打开原始文件时,计算机判断原始文件的存储文件所在目录是否存在文件名例如为“原始文件的存储文件名.tmp”的备份文件。如果存在文件名例如为“原始文件的存储文件名.tmp”的备份文件,则读取这个备份文件到内存。接着将原始文件的存储文件定位到原始“中央目录结构区”的起始位置,写入备份的原有“中央目录结构区”和“中央目录结束区”数据,即可恢复原始文件的存储文件,这种情况使用内存备份,文件恢复速度快。 当对原始文件的存储文件恢复完成之后,则删除目标索引数据的备份文件,再打开恢复后的原始文件。For the case where the saving of the target file is interrupted due to abnormal power failure, when the user opens the original file again, the computer determines whether the directory where the original file is stored has a file name such as "Stored file name of the original file.tmp" backup file. If there is a backup file whose file name is, for example, "storage file name of the original file. tmp", the backup file is read into the memory. Then, locate the storage file of the original file to the starting position of the original "central directory structure area", and write the backup data of the original "central directory structure area" and "central directory end area" to restore the storage file of the original file , in this case, the memory backup is used, and the file recovery speed is fast. After the restoration of the storage file of the original file is completed, the backup file of the target index data is deleted, and the restored original file is opened.
图6是本申请提供的文件存储装置的一实施例的结构示意图。如图6所示,本申请提供的文件存储装置600可以包括:FIG. 6 is a schematic structural diagram of an embodiment of a file storage device provided by the present application. As shown in FIG. 6, the file storage device 600 provided by the present application may include:
修改信息获取模块610,用于响应于针对目标文件的存储请求,获取对原始文件的修改信息,其中,目标文件是对原始文件修改后的文件,原始文件的存储文件可以包括至少一个数据文件和至少一个数据文件对应的目标索引数据;The modification information obtaining module 610 is configured to obtain modification information of the original file in response to the storage request for the target file, wherein the target file is a modified file of the original file, and the storage file of the original file may include at least one data file and Target index data corresponding to at least one data file;
新写入数据确定模块620,用于基于修改信息确定新写入数据,新写入数据至少可以包括更新后的目标索引数据;a new write data determination module 620, configured to determine new write data based on the modification information, and the new write data may at least include updated target index data;
存储模块630,用于将目标索引数据替换为新写入数据,得到目标文件的存储文件。The storage module 630 is configured to replace the target index data with newly written data to obtain a storage file of the target file.
在本申请的实施例中,在保存修改后的目标文件时,基于对原始文件的修改信息可以确定新写入数据。其中,新写入数据至少可以包括更新后的目标索引数据。在对目标文件进行存储时,只需要将原始文件的存储文件中的目标索引数据替换为新写入数据,即可以实现对目标文件的存储,即使用增量方式保存了目标文件,减少了需要重新保存的数据量,提高了修改后的文件的存储效率。In the embodiment of the present application, when the modified target file is saved, the newly written data can be determined based on the modification information of the original file. The newly written data may at least include updated target index data. When storing the target file, it is only necessary to replace the target index data in the storage file of the original file with the newly written data, so that the target file can be stored, that is, the target file is saved in an incremental manner, reducing the need for The amount of data to be re-saved improves the storage efficiency of modified files.
在本申请的一些实施例中,修改信息可以包括新增的数据文件和/或删除的数据文件;其中,新写入数据确定模块620用于:In some embodiments of the present application, the modification information may include newly added data files and/or deleted data files; wherein, the newly written data determination module 620 is used for:
在修改信息包括新增的数据文件的情况下,基于修改信息,得到更新后的目标索引数据,并将新增的数据文件和更新后的目标索引数据,确定为新写入数据;In the case where the modification information includes a newly added data file, based on the modification information, the updated target index data is obtained, and the newly added data file and the updated target index data are determined as newly written data;
在修改信息包括删除的数据文件的标识的情况下,基于修改信息,得到更新后的目标索引数据,并将更新后的目标索引数据,确定为新写入数据。When the modification information includes the identifier of the deleted data file, based on the modification information, the updated target index data is obtained, and the updated target index data is determined as newly written data.
在本申请的一些实施例中,目标索引数据可以包括第一索引数据和第二索引数据,第一索引数据可以包括至少一个数据文件中每个数据文件的索引数据,第二索引数据可以包括第一索引数据的索引数据;其中,新写入数据确定模块620用于:In some embodiments of the present application, the target index data may include first index data and second index data, the first index data may include index data of each data file in the at least one data file, and the second index data may include the first index data. Index data of index data; wherein, the newly written data determination module 620 is used for:
基于修改信息更新第一索引数据,得到更新后的第一索引数据;Update the first index data based on the modification information to obtain the updated first index data;
根据更新后的第一索引数据,更新第二索引数据,得到更新后的第二索引数据;According to the updated first index data, update the second index data to obtain the updated second index data;
将更新后的第一索引数据和更新后的第二索引数据确定为更新后的目标索引数据。The updated first index data and the updated second index data are determined as the updated target index data.
在本申请的一些实施例中,新写入数据确定模块620用于:In some embodiments of the present application, the newly written data determination module 620 is used to:
在修改信息包括新增的数据文件的情况下,在第一索引数据中增加新增的数据文件的索引数据,得到更新后的第一索引数据;In the case that the modification information includes a newly added data file, the index data of the newly added data file is added to the first index data to obtain the updated first index data;
在修改信息包括删除的数据文件的标识情况下,从第一索引数据中删除标识对应的删除的数据文件的索引数据,得到更新后的第一索引数据。In the case where the modification information includes the identifier of the deleted data file, the index data corresponding to the identifier of the deleted data file is deleted from the first index data to obtain the updated first index data.
在本申请的一些实施例中,存储模块630用于:In some embodiments of the present application, the storage module 630 is used to:
在保持至少一个数据文件不变的情况下,将目标索引数据替换为新写入数据,得到目标文件的存储文件。Under the condition of keeping at least one data file unchanged, replace the target index data with newly written data to obtain a storage file of the target file.
在本申请的一些实施例中,修改信息可以包括删除的数据文件的标识;In some embodiments of the present application, the modification information may include the identification of the deleted data file;
其中,存储模块630用于:Wherein, the storage module 630 is used for:
在确定标识对应的删除的数据文件的大小与原始文件的存储文件的大小的比值大于第一预设比值的情况下,从至少一个数据文件中删除标识对应的删除的数据文件,并将目标索引数据替换为新写入数据,得到目标文件的存储文件。In the case where it is determined that the ratio of the size of the deleted data file corresponding to the identification to the size of the storage file of the original file is greater than the first preset ratio, delete the deleted data file corresponding to the identification from at least one data file, and set the target index The data is replaced with the newly written data, and the storage file of the target file is obtained.
在本申请的一些实施例中,文件存储装置600还可以包括保存模块,用于:In some embodiments of the present application, the file storage device 600 may further include a saving module for:
将目标索引数据保存在内存中;Save the target index data in memory;
和/或,and / or,
将目标索引数据保存在磁盘中。Save the target index data to disk.
根据本申请实施例的文件存储装置的其他细节与以上结合图3~图6描述的根据本申请实施例的文件存储方法类似,在此不再赘述。Other details of the file storage device according to the embodiment of the present application are similar to the file storage method according to the embodiment of the present application described above with reference to FIG. 3 to FIG. 6 , and details are not repeated here.
结合图3至图6描述的根据本申请实施例的文件存储方法和装置可以由文件存储设备来实现。图7是根据本申请提供的文件存储设备的一个实施例的结构示意图。The file storage method and apparatus according to the embodiments of the present application described in conjunction with FIG. 3 to FIG. 6 may be implemented by a file storage device. FIG. 7 is a schematic structural diagram of an embodiment of a file storage device provided according to the present application.
文件存储设备700可以包括处理器701以及存储有计算机程序指令的存储器702。The file storage device 700 may include a processor 701 and a memory 702 storing computer program instructions.
具体地,上述处理器701可以包括中央处理器(CPU),或者特定集成电路(Application Specific Integrated Circuit,ASIC),或者可以被配置成实施本申请实施例的一个或多个集成电路。Specifically, the above-mentioned processor 701 may include a central processing unit (CPU), or a specific integrated circuit (Application Specific Integrated Circuit, ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
存储器702可以包括用于数据或指令的大容量存储器。举例来说而非限制,存储器702可包括硬盘驱动器(Hard Disk Drive,HDD)、软盘驱动器、闪存、光盘、磁光盘、磁带或通用串行总线(Universal Serial Bus,USB)驱动器或者两个或更多个以上这些的组合。在合适的情况下,存储器702可包括可移除或不可移除(或固定)的介质。在合适的情况下,存储器702可在文件存储设备700的内部或外部。在特定实施例中,存 储器702是非易失性固态存储器。 Memory 702 may include mass storage for data or instructions. By way of example and not limitation, memory 702 may include a Hard Disk Drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a Universal Serial Bus (USB) drive or two or more A combination of more than one of the above. Memory 702 may include removable or non-removable (or fixed) media, where appropriate. Memory 702 may be internal or external to file storage device 700, where appropriate. In certain embodiments, memory 702 is non-volatile solid state memory.
在特定实施例中,存储器702可以包括只读存储器(ROM)。在合适的情况下,该ROM可以是掩模编程的ROM、可编程ROM(PROM)、可擦除PROM(EPROM)、电可擦除PROM(EEPROM)、电可改写ROM(EAROM)或闪存或者两个或更多个以上这些的组合。In certain embodiments, memory 702 may include read only memory (ROM). Where appropriate, the ROM may be a mask programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), electrically rewritable ROM (EAROM) or flash memory or A combination of two or more of the above.
存储器可包括只读存储器(ROM),随机存取存储器(RAM),磁盘存储介质设备,光存储介质设备,闪存设备,电气、光学或其他物理/有形的存储器存储设备。因此,通常,存储器包括一个或多个编码有包括计算机可执行指令的软件的有形(非暂态)计算机可读存储介质(例如,存储器设备),并且当该软件被执行(例如,由一个或多个处理器)时,其可操作来执行参考根据本申请的文件存储的方法所描述的操作。Memory may include read only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical/tangible memory storage devices. Thus, typically, a memory includes one or more tangible (non-transitory) computer-readable storage media (eg, memory devices) encoded with software including computer-executable instructions, and when the software is executed (eg, by a or multiple processors), it is operable to perform the operations described with reference to the method of file storage according to the present application.
处理器701通过读取并执行存储器702中存储的计算机程序指令,以实现上述实施例中的任意一种文件存储方法。The processor 701 reads and executes the computer program instructions stored in the memory 702 to implement any one of the file storage methods in the foregoing embodiments.
在一个示例中,文件存储设备还可包括通信接口703和总线710。其中,如图7所示,处理器701、存储器702、通信接口703通过总线710连接并完成相互间的通信。In one example, the file storage device may also include a communication interface 703 and a bus 710 . Among them, as shown in FIG. 7 , the processor 701 , the memory 702 , and the communication interface 703 are connected through the bus 710 and complete the mutual communication.
通信接口703,主要用于实现本申请实施例中各模块、装置、单元和/或设备之间的通信。The communication interface 703 is mainly used to implement communication between modules, apparatuses, units and/or devices in the embodiments of the present application.
总线710可以包括硬件、软件或两者,将文件存储设备的部件彼此耦接在一起。举例来说而非限制,总线可包括加速图形端口(AGP)或其他图形总线、增强工业标准架构(EISA)总线、前端总线(FSB)、超传输(HT)互连、工业标准架构(ISA)总线、无限带宽互连、低引脚数(LPC)总线、存储器总线、微信道架构(MCA)总线、外围组件互连(PCI)总线、PCI-Express(PCI-X)总线、串行高级技术附件(SATA)总线、视频电子标准协会局部(VLB)总线或其他合适的总线或者两个或更多个以上这些的组合。在合适的情况下,总线710可包括一个或多个总线。尽管本申请实施例描述和示出了特定的总线,但本申请考虑任何合适的总线或互连。The bus 710 may include hardware, software, or both, coupling the components of the file storage device to each other. By way of example and not limitation, the bus may include Accelerated Graphics Port (AGP) or other graphics bus, Enhanced Industry Standard Architecture (EISA) bus, Front Side Bus (FSB), HyperTransport (HT) Interconnect, Industry Standard Architecture (ISA) Bus, Infiniband Interconnect, Low Pin Count (LPC) Bus, Memory Bus, Microchannel Architecture (MCA) Bus, Peripheral Component Interconnect (PCI) Bus, PCI-Express (PCI-X) Bus, Serial Advanced Technology Attachment (SATA) bus, Video Electronics Standards Association Local (VLB) bus or other suitable bus or a combination of two or more of the above. Bus 710 may include one or more buses, where appropriate. Although embodiments of this application describe and illustrate a particular bus, this application contemplates any suitable bus or interconnect.
另外,结合上述实施例中的文件存储方法,本申请实施例可提供一种计算机存储介质来实现。该计算机存储介质上存储有计算机程序指令;该计算机程序指令被处理器执行时实现上述实施例中的任意一种文件存储方法。计算机存储介质的示例包括非暂态计算机存储介质,如电子电路、半导体存储器设备、ROM、随机存取存储器、闪 存、可擦除ROM(EROM)、软盘、CD-ROM、光盘、硬盘。In addition, in combination with the file storage method in the foregoing embodiment, the embodiment of the present application may provide a computer storage medium for implementation. Computer program instructions are stored on the computer storage medium; when the computer program instructions are executed by the processor, any one of the file storage methods in the foregoing embodiments is implemented. Examples of computer storage media include non-transitory computer storage media such as electronic circuits, semiconductor memory devices, ROM, random access memory, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks.
需要明确的是,本申请并不局限于上文所描述并在图中示出的特定配置和处理。为了简明起见,这里省略了对已知方法的详细描述。在上述实施例中,描述和示出了若干具体的步骤作为示例。但是,本申请的方法过程并不限于所描述和示出的具体步骤,本领域的技术人员可以在领会本申请的精神后,作出各种改变、修改和添加,或者改变步骤之间的顺序。To be clear, the present application is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above-described embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the sequence of steps after comprehending the spirit of the present application.
以上所述的结构框图中所示的功能块可以实现为硬件、软件、固件或者它们的组合。当以硬件方式实现时,其可以例如是电子电路、专用集成电路(ASIC)、适当的固件、插件、功能卡等等。当以软件方式实现时,本申请的元素是被用于执行所需任务的程序或者代码段。程序或者代码段可以存储在机器可读介质中,或者通过载波中携带的数据信号在传输介质或者通信链路上传送。“机器可读介质”可以包括能够存储或传输信息的任何介质。机器可读介质的例子包括电子电路、半导体存储器设备、ROM、闪存、可擦除ROM(EROM)、软盘、CD-ROM、光盘、硬盘、光纤介质、射频(RF)链路,等等。代码段可以经由诸如因特网、内联网等的计算机网络被下载。The functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an application specific integrated circuit (ASIC), suitable firmware, a plug-in, a function card, or the like. When implemented in software, elements of the present application are programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted over a transmission medium or communication link by a data signal carried in a carrier wave. A "machine-readable medium" may include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, and the like. The code segments may be downloaded via a computer network such as the Internet, an intranet, or the like.
还需要说明的是,本申请中提及的示例性实施例,基于一系列的步骤或者装置描述一些方法或系统。但是,本申请不局限于上述步骤的顺序,也就是说,可以按照实施例中提及的顺序执行步骤,也可以不同于实施例中的顺序,或者若干步骤同时执行。It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above steps, that is, the steps may be performed in the order mentioned in the embodiment, or may be different from the order in the embodiment, or several steps may be performed simultaneously.
上面参考根据本申请的实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本申请的各方面。应当理解,流程图和/或框图中的每个方框以及流程图和/或框图中各方框的组合可以由计算机程序指令实现。这些计算机程序指令可被提供给通用计算机、专用计算机、或其它可编程数据处理装置的处理器,以产生一种机器,使得经由计算机或其它可编程数据处理装置的处理器执行的这些指令使能对流程图和/或框图的一个或多个方框中指定的功能/动作的实现。这种处理器可以是但不限于是通用处理器、专用处理器、特殊应用处理器或者现场可编程逻辑电路。还可理解,框图和/或流程图中的每个方框以及框图和/或流程图中的方框的组合,也可以由执行指定的功能或动作的专用硬件来实现,或可由专用硬件和计算机指令的组合来实现。Aspects of the present application are described above with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the present application. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine such that execution of the instructions via the processor of the computer or other programmable data processing apparatus enables the Implementation of the functions/acts specified in one or more blocks of the flowchart and/or block diagrams. Such processors may be, but are not limited to, general purpose processors, special purpose processors, application specific processors, or field programmable logic circuits. It will also be understood that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can also be implemented by special purpose hardware for performing the specified functions or actions, or by special purpose hardware and/or A combination of computer instructions is implemented.
以上所述,仅为本申请的具体实施方式,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的系统、模块和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。应理解,本申请的保护范围并不局 限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。The above are only specific implementations of the present application. Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described systems, modules and units may refer to the foregoing method embodiments. The corresponding process in , will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should all cover within the scope of protection of this application.

Claims (15)

  1. 一种文件存储方法,包括:A file storage method, comprising:
    响应于针对目标文件的存储请求,获取对原始文件的修改信息,其中,所述目标文件是对所述原始文件修改后的文件,所述原始文件的存储文件包括至少一个数据文件和所述至少一个数据文件对应的目标索引数据;In response to the storage request for the target file, the modification information of the original file is obtained, wherein the target file is a modified file of the original file, and the storage file of the original file includes at least one data file and the at least one data file. The target index data corresponding to a data file;
    基于所述修改信息确定新写入数据,所述新写入数据至少包括更新后的目标索引数据;Determine new write data based on the modification information, and the new write data includes at least updated target index data;
    将所述目标索引数据替换为所述新写入数据,得到所述目标文件的存储文件。Replace the target index data with the newly written data to obtain a storage file of the target file.
  2. 根据权利要求1所述的方法,其中,所述修改信息包括新增的数据文件和/或删除的数据文件;The method according to claim 1, wherein the modification information includes newly added data files and/or deleted data files;
    其中,所述基于所述修改信息确定新写入数据,包括:Wherein, determining the newly written data based on the modification information includes:
    在所述修改信息包括新增的数据文件的情况下,基于所述修改信息得到更新后的目标索引数据,并将所述新增的数据文件和所述更新后的目标索引数据,确定为所述新写入数据;In the case where the modification information includes a newly added data file, the updated target index data is obtained based on the modification information, and the newly added data file and the updated target index data are determined as the Describe the newly written data;
    在所述修改信息包括删除的数据文件的标识的情况下,基于所述修改信息得到更新后的目标索引数据,并将所述更新后的目标索引数据,确定为所述新写入数据。When the modification information includes the identifier of the deleted data file, the updated target index data is obtained based on the modification information, and the updated target index data is determined as the newly written data.
  3. 根据权利要求2所述的方法,其中,所述目标索引数据包括第一索引数据和第二索引数据,所述第一索引数据包括所述至少一个数据文件中每个数据文件的索引数据,所述第二索引数据包括所述第一索引数据的索引数据;The method of claim 2, wherein the target index data includes first index data and second index data, the first index data includes index data of each data file in the at least one data file, and the The second index data includes index data of the first index data;
    其中,所述基于所述修改信息得到更新后的目标索引数据,包括:Wherein, obtaining the updated target index data based on the modification information includes:
    基于所述修改信息更新所述第一索引数据,得到更新后的第一索引数据;Update the first index data based on the modification information to obtain the updated first index data;
    根据所述更新后的第一索引数据,更新所述第二索引数据,得到更新后的第二索引数据;According to the updated first index data, update the second index data to obtain updated second index data;
    将所述更新后的第一索引数据和所述更新后的第二索引数据确定为所述更新后的目标索引数据。The updated first index data and the updated second index data are determined as the updated target index data.
  4. 根据权利要求3所述的方法,其中,所述基于所述修改信息更新所述第一索引数据,得到更新后的第一索引数据,包括:The method according to claim 3, wherein the updating the first index data based on the modification information to obtain the updated first index data comprises:
    在所述修改信息包括新增的数据文件的情况下,在所述第一索引数据中增加所述新增的数据文件的索引数据,得到更新后的第一索引数据;In the case that the modification information includes a newly added data file, the index data of the newly added data file is added to the first index data to obtain the updated first index data;
    在所述修改信息包括删除的数据文件的标识情况下,从所述第一索引数据中删除所述标识对应的删除的数据文件的索引数据,得到更新后的第一索引数据。In the case where the modification information includes the identifier of the deleted data file, the index data of the deleted data file corresponding to the identifier is deleted from the first index data, and the updated first index data is obtained.
  5. 根据权利要求1所述的方法,其中,所述将所述目标索引数据替换为所述新写入数据,得到所述目标文件的存储文件,包括:The method according to claim 1, wherein the replacing the target index data with the newly written data to obtain the storage file of the target file comprises:
    在保持所述至少一个数据文件不变的情况下,将所述目标索引数据替换为所述新写入数据,得到所述目标文件的存储文件。Under the condition that the at least one data file is kept unchanged, the target index data is replaced with the newly written data to obtain a storage file of the target file.
  6. 根据权利要求1所述的方法,其中,所述修改信息包括删除的数据文件的标识;The method of claim 1, wherein the modification information includes an identification of the deleted data file;
    其中,所述将所述目标索引数据替换为所述新写入数据,得到所述目标文件的存储文件,包括:Wherein, replacing the target index data with the newly written data to obtain the storage file of the target file includes:
    在确定所述标识对应的删除的数据文件的大小与所述原始文件的存储文件的大小的比值大于第一预设比值的情况下,从所述至少一个数据文件中删除所述标识对应的删除的数据文件,并将所述目标索引数据替换为所述新写入数据,得到所述目标文件的存储文件。In the case where it is determined that the ratio of the size of the deleted data file corresponding to the identifier to the size of the storage file of the original file is greater than a first preset ratio, delete the deletion corresponding to the identifier from the at least one data file and replace the target index data with the newly written data to obtain the storage file of the target file.
  7. 根据权利要求1所述的方法,其中,在所述响应于针对目标文件的存储请求,获取对原始文件的修改信息之前,所述方法还包括:The method according to claim 1, wherein, before acquiring the modification information on the original file in response to the storage request for the target file, the method further comprises:
    将所述目标索引数据保存在内存中;和/或storing the target index data in memory; and/or
    将所述目标索引数据保存在磁盘中。The target index data is saved in the disk.
  8. 一种文件存储装置,包括:A file storage device, comprising:
    修改信息获取模块,用于响应于针对目标文件的存储请求,获取原始文件的修改信息,其中,所述目标文件是对所述原始文件修改后的文件, 所述原始文件的存储文件包括至少一个数据文件和所述至少一个数据文件对应的目标索引数据;A modification information acquisition module, configured to acquire modification information of an original file in response to a storage request for a target file, wherein the target file is a modified file of the original file, and the storage file of the original file includes at least one data files and target index data corresponding to the at least one data file;
    新写入数据确定模块,用于基于所述修改信息确定新写入数据,所述新写入数据至少包括更新后的目标索引数据;a new write data determination module, configured to determine new write data based on the modification information, and the new write data includes at least updated target index data;
    存储模块,用于将所述目标索引数据替换为所述新写入数据,得到所述目标文件的存储文件。A storage module, configured to replace the target index data with the newly written data to obtain a storage file of the target file.
  9. 根据权利要求8所述的装置,其中,所述修改信息包括新增的数据文件和/或删除的数据文件;The apparatus according to claim 8, wherein the modification information includes newly added data files and/or deleted data files;
    其中,所述新写入数据确定模块被配置用于:Wherein, the new write data determination module is configured to:
    在所述修改信息包括新增的数据文件的情况下,基于所述修改信息得到更新后的目标索引数据,并将所述新增的数据文件和所述更新后的目标索引数据,确定为所述新写入数据;In the case where the modification information includes a newly added data file, the updated target index data is obtained based on the modification information, and the newly added data file and the updated target index data are determined as the Describe the newly written data;
    在所述修改信息包括删除的数据文件的标识的情况下,基于所述修改信息得到更新后的目标索引数据,并将所述更新后的目标索引数据,确定为所述新写入数据。When the modification information includes the identifier of the deleted data file, the updated target index data is obtained based on the modification information, and the updated target index data is determined as the newly written data.
  10. 根据权利要求9所述的装置,其中,所述目标索引数据包括第一索引数据和第二索引数据,所述第一索引数据包括所述至少一个数据文件中每个数据文件的索引数据,所述第二索引数据包括所述第一索引数据的索引数据;The apparatus of claim 9, wherein the target index data includes first index data and second index data, the first index data includes index data of each data file in the at least one data file, and the The second index data includes index data of the first index data;
    其中,所述新写入数据确定模块被配置用于:Wherein, the new write data determination module is configured to:
    基于所述修改信息更新所述第一索引数据,得到更新后的第一索引数据;Update the first index data based on the modification information to obtain the updated first index data;
    根据所述更新后的第一索引数据,更新所述第二索引数据,得到更新后的第二索引数据;According to the updated first index data, update the second index data to obtain updated second index data;
    将所述更新后的第一索引数据和所述更新后的第二索引数据确定为所述更新后的目标索引数据。The updated first index data and the updated second index data are determined as the updated target index data.
  11. 根据权利要求10所述的装置,其中,所述新写入数据确定模块被配置用于:The apparatus of claim 10, wherein the new write data determination module is configured to:
    在所述修改信息包括新增的数据文件的情况下,在所述第一索引数据中增加所述新增的数据文件的索引数据,得到更新后的第一索引数据;In the case that the modification information includes a newly added data file, the index data of the newly added data file is added to the first index data to obtain the updated first index data;
    在所述修改信息包括删除的数据文件的标识情况下,从所述第一索引数据中删除所述标识对应的删除的数据文件的索引数据,得到更新后的第一索引数据。In the case where the modification information includes the identifier of the deleted data file, the index data of the deleted data file corresponding to the identifier is deleted from the first index data, and the updated first index data is obtained.
  12. 根据权利要求8所述的装置,其中,所述存储模块被配置用于:The apparatus of claim 8, wherein the storage module is configured to:
    在保持所述至少一个数据文件不变的情况下,将所述目标索引数据替换为所述新写入数据,得到所述目标文件的存储文件。Under the condition that the at least one data file is kept unchanged, the target index data is replaced with the newly written data to obtain a storage file of the target file.
  13. 根据权利要求8所述的装置,其中,所述修改信息包括删除的数据文件的标识;The apparatus of claim 8, wherein the modification information includes an identification of the deleted data file;
    其中,所述存储模块被配置用于:Wherein, the storage module is configured to:
    在确定所述标识对应的删除的数据文件的大小与所述原始文件的存储文件的大小的比值大于第一预设比值的情况下,从所述至少一个数据文件中删除所述标识对应的删除的数据文件,并将所述目标索引数据替换为所述新写入数据,得到所述目标文件的存储文件。In the case where it is determined that the ratio of the size of the deleted data file corresponding to the identifier to the size of the storage file of the original file is greater than a first preset ratio, delete the deletion corresponding to the identifier from the at least one data file and replace the target index data with the newly written data to obtain the storage file of the target file.
  14. 一种文件存储设备,包括:处理器以及存储有计算机程序指令的存储器,A file storage device, comprising: a processor and a memory storing computer program instructions,
    所述处理器执行所述计算机程序指令时实现如权利要求1-7任意一项所述的文件存储方法。When the processor executes the computer program instructions, the file storage method according to any one of claims 1-7 is implemented.
  15. 一种计算机存储介质,所述计算机存储介质上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现如权利要求1-7任意一项所述的文件存储方法。A computer storage medium, where computer program instructions are stored thereon, and when the computer program instructions are executed by a processor, the file storage method according to any one of claims 1-7 is implemented.
PCT/CN2020/133445 2020-08-19 2020-12-02 File storage method and apparatus, device, and medium WO2022036927A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010836266.5 2020-08-19
CN202010836266.5A CN111984597B (en) 2020-08-19 2020-08-19 File storage method, device, equipment and medium

Publications (1)

Publication Number Publication Date
WO2022036927A1 true WO2022036927A1 (en) 2022-02-24

Family

ID=73435680

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/133445 WO2022036927A1 (en) 2020-08-19 2020-12-02 File storage method and apparatus, device, and medium

Country Status (2)

Country Link
CN (1) CN111984597B (en)
WO (1) WO2022036927A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114936010A (en) * 2022-07-20 2022-08-23 阿里巴巴(中国)有限公司 Data processing method, device, equipment and medium
CN116624361A (en) * 2023-04-11 2023-08-22 北京通嘉宏瑞科技有限公司 Vacuum pump working method, device, computer equipment and storage medium

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984597B (en) * 2020-08-19 2023-12-08 安徽鸿程光电有限公司 File storage method, device, equipment and medium
CN113239001A (en) * 2021-05-21 2021-08-10 珠海金山网络游戏科技有限公司 Data storage method and device
CN113553335A (en) * 2021-07-26 2021-10-26 北京东方国信科技股份有限公司 Data updating method and device for columnar storage file
CN113779321B (en) * 2021-09-06 2023-06-23 深圳创维数字技术有限公司 Electronic whiteboard file storage method and device, electronic whiteboard and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170249140A1 (en) * 2014-05-30 2017-08-31 Guangzhou Ucweb Computer Technology Co., Ltd. Method and apparatus for incremental upgrade
CN107315806A (en) * 2017-06-26 2017-11-03 杭州时趣信息技术有限公司 A kind of embedded storage method and device based on file system
CN109408462A (en) * 2018-09-17 2019-03-01 深圳点猫科技有限公司 A kind of document storage management method and electronic equipment based on educational system
CN110287201A (en) * 2019-07-02 2019-09-27 重庆紫光华山智安科技有限公司 Data access method, device, equipment and storage medium
CN110532236A (en) * 2019-08-21 2019-12-03 广联达科技股份有限公司 Increment updating method, system and the medium of compressed file
CN111984597A (en) * 2020-08-19 2020-11-24 安徽鸿程光电有限公司 File storage method, device, equipment and medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014175880A1 (en) * 2013-04-24 2014-10-30 Empire Technology Development Llc Computing devices with multi-layer file systems
CN104572762B (en) * 2013-10-24 2019-04-12 杭州海康威视数字技术股份有限公司 The method and apparatus for deleting and restoring video file
CN110688347A (en) * 2019-09-24 2020-01-14 Oppo广东移动通信有限公司 File storage method, file storage device and terminal equipment
CN110765076B (en) * 2019-10-25 2023-04-21 北京奇艺世纪科技有限公司 Data storage method, device, electronic equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170249140A1 (en) * 2014-05-30 2017-08-31 Guangzhou Ucweb Computer Technology Co., Ltd. Method and apparatus for incremental upgrade
CN107315806A (en) * 2017-06-26 2017-11-03 杭州时趣信息技术有限公司 A kind of embedded storage method and device based on file system
CN109408462A (en) * 2018-09-17 2019-03-01 深圳点猫科技有限公司 A kind of document storage management method and electronic equipment based on educational system
CN110287201A (en) * 2019-07-02 2019-09-27 重庆紫光华山智安科技有限公司 Data access method, device, equipment and storage medium
CN110532236A (en) * 2019-08-21 2019-12-03 广联达科技股份有限公司 Increment updating method, system and the medium of compressed file
CN111984597A (en) * 2020-08-19 2020-11-24 安徽鸿程光电有限公司 File storage method, device, equipment and medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114936010A (en) * 2022-07-20 2022-08-23 阿里巴巴(中国)有限公司 Data processing method, device, equipment and medium
CN114936010B (en) * 2022-07-20 2022-12-27 阿里巴巴(中国)有限公司 Data processing method, device, equipment and medium
CN116624361A (en) * 2023-04-11 2023-08-22 北京通嘉宏瑞科技有限公司 Vacuum pump working method, device, computer equipment and storage medium
CN116624361B (en) * 2023-04-11 2024-03-22 北京通嘉宏瑞科技有限公司 Vacuum pump working method, device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN111984597B (en) 2023-12-08
CN111984597A (en) 2020-11-24

Similar Documents

Publication Publication Date Title
WO2022036927A1 (en) File storage method and apparatus, device, and medium
US6585777B1 (en) Method for managing embedded files for a document saved in HTML format
US20230325287A1 (en) Data backup method and apparatus, data recovery method and apparatus, and storage medium
US20110055500A1 (en) Data Storage Snapshot With Reduced Copy-On-Write
CN110019498B (en) Log synchronization method and device, storage medium and electronic equipment
US20070299888A1 (en) Automatically maintaining metadata in a file backup system
CN106844102B (en) Data recovery method and device
US10609141B2 (en) Methods and apparatuses for cluster switching
CN110058962B (en) Method, apparatus and computer program product for determining consistency level of virtual machine snapshots
WO2017113317A1 (en) File editing method and file editor
WO2019109514A1 (en) Datasheet backup method, device, electronic apparatus and medium
WO2016177075A1 (en) Method of checking associative relationship of service data, device and readable storage medium utilizing same
US20140222876A1 (en) File system extended attribute support in an operating system with restricted extended attributes
US20100094821A1 (en) System and Method for Inserting a PDF Shared Resource Back Into a PDF Statement
CN112231288A (en) Log storage method and device and medium
CN109542860B (en) Service data management method based on HDFS and terminal equipment
CN110674084A (en) Method, apparatus, and computer-readable storage medium for data protection
US10877992B2 (en) Updating a database
CN111753141A (en) Data management method and related equipment
US10168948B2 (en) Replicating data in a data storage system
CN113625952A (en) Object storage method, device, equipment and storage medium
CN110636042B (en) Method, device and equipment for updating verified block height of server
CN109740027B (en) Data exchange method, device, server and storage medium
CN113505153A (en) Memorandum backup method based on iOS system and related equipment
CN111444194A (en) Method, device and equipment for clearing indexes in block chain type account book

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20950130

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20950130

Country of ref document: EP

Kind code of ref document: A1