Movatterモバイル変換


[0]ホーム

URL:


CN119248736A - File synchronization method, electronic device and storage medium - Google Patents

File synchronization method, electronic device and storage medium
Download PDF

Info

Publication number
CN119248736A
CN119248736ACN202410386081.7ACN202410386081ACN119248736ACN 119248736 ACN119248736 ACN 119248736ACN 202410386081 ACN202410386081 ACN 202410386081ACN 119248736 ACN119248736 ACN 119248736A
Authority
CN
China
Prior art keywords
file
electronic device
synchronization
metadata
local
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410386081.7A
Other languages
Chinese (zh)
Inventor
刘能宾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co LtdfiledCriticalHonor Device Co Ltd
Priority to CN202410386081.7ApriorityCriticalpatent/CN119248736A/en
Publication of CN119248736ApublicationCriticalpatent/CN119248736A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本申请提供了一种文件同步方法、电子设备及存储介质,涉及数据处理技术领域。该方法应用于电子设备,电子设备所在的信任环还包括至少一个受信任电子设备,该方法包括:获取至少一个受信任电子设备发送的待同步文件;根据待同步文件生成临时同步文件;校验临时同步文件;当临时同步文件校验通过时,将临时同步文件同步至文件系统中。这种实现方式中,对临时同步文件进行了校验,能够保证电子设备接收到的文件与源文件一致,保证了文件同步的完整性,提高了文件同步的准确率。对临时同步文件进行校验,还能够保证同步的文件不被篡改,避免信任环内的电子设备的系统受到恶意软件或病毒的攻击,提高了文件同步过程的安全性。

The present application provides a file synchronization method, an electronic device and a storage medium, and relates to the field of data processing technology. The method is applied to an electronic device, and the trust ring in which the electronic device is located also includes at least one trusted electronic device. The method includes: obtaining a file to be synchronized sent by at least one trusted electronic device; generating a temporary synchronization file based on the file to be synchronized; verifying the temporary synchronization file; when the temporary synchronization file passes the verification, synchronizing the temporary synchronization file to the file system. In this implementation, the temporary synchronization file is verified, which can ensure that the file received by the electronic device is consistent with the source file, ensure the integrity of the file synchronization, and improve the accuracy of the file synchronization. Verifying the temporary synchronization file can also ensure that the synchronized file is not tampered with, avoid the system of the electronic device in the trust ring from being attacked by malware or viruses, and improve the security of the file synchronization process.

Description

File synchronization method, electronic device and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a file synchronization method, an electronic device, and a storage medium.
Background
With the development of communication technology, distributed technology is increasingly applied to electronic devices. The distributed technology brings easier and more convenient experience for users in some scenes such as offices, data storage, data access and the like.
For example, in a distributed file synchronization scenario, cell phones and other electronic devices (e.g., tablet computers, notebook computers, home storage devices, etc.) communicate via near field. For example, near field communication such as wireless fidelity (WIRELESS FIDELITY, wi-Fi), bluetooth (BT), peer-to-peer (P2P) is used to form a local area network, and a trust ring is established to synchronize files in the mobile phone to other electronic devices.
However, in use, the file synchronization process in the related art is found to be unsafe and error-prone.
Disclosure of Invention
The application provides a file synchronization method, electronic equipment and a storage medium, which can ensure the integrity of file synchronization in the file synchronization process, improve the accuracy of file synchronization and improve the safety of the file synchronization process.
In a first aspect, the application provides a file synchronization method applied to electronic equipment, wherein a trust ring where the electronic equipment is located also comprises at least one trusted electronic equipment, and the method comprises the steps of obtaining a file to be synchronized sent by the at least one trusted electronic equipment; generating a temporary synchronous file according to the file to be synchronized, checking the temporary synchronous file, and synchronizing the temporary synchronous file into a file system when the temporary synchronous file passes the check.
The file to be synchronized is the file to be synchronized. In the embodiment of the application, the file to be synchronized can be a file for synchronization, which is sent by the trusted electronic device to the electronic device.
Alternatively, verifying the temporary synchronization file may include verifying the integrity of the temporary synchronization file, the consistency of the temporary synchronization file with the source file, whether the temporary synchronization file functions properly, and the like.
In the implementation mode, the temporary synchronous file is checked, so that the file received by the electronic equipment is consistent with the source file, the integrity and consistency of file synchronization are ensured, the finally synchronized file is accurate, and the accuracy of file synchronization is improved. The temporary synchronous file is checked, the synchronous file is not tampered, the error is not easy to occur in the synchronous process, the system of the electronic equipment in the trust ring is effectively prevented from being attacked by malicious software or viruses, and the safety of the file synchronous process is improved.
With reference to the first aspect, in some implementation manners of the first aspect, verifying the temporary synchronization file includes obtaining source end metadata sent by at least one trusted electronic device, generating a verification value corresponding to the temporary synchronization file and a verification value corresponding to the source end metadata, and determining that the temporary synchronization file passes the verification when detecting that the verification value of the temporary synchronization file is consistent with the verification value of the source end metadata.
Optionally, the check value of the temporary synchronization file and the check value of the source metadata may each include a weak hash value, a strong hash value, a checksum, a hash-based message authentication code, and the like.
In the implementation mode, the consistency check is equivalent to that of the temporary synchronous file and the source file, and the file is synchronized when the temporary synchronous file and the source file are consistent, so that the finally synchronized file is accurate, and the accuracy of file synchronization is improved. The temporary synchronous file is checked, the synchronous file is not tampered, the error is not easy to occur in the synchronous process, the system of the electronic equipment in the trust ring is effectively prevented from being attacked by malicious software or viruses, and the safety of the file synchronous process is improved.
With reference to the first aspect, in some implementations of the first aspect, synchronizing the temporary synchronization file into the file system includes deleting a local file corresponding to the temporary synchronization file in the file system, modifying a file name of the temporary synchronization file, and storing the temporary synchronization file after the modification of the file name in the file system.
Optionally, the file name of the temporary synchronization file after modification is consistent with the file name of the local file.
In the implementation mode, the local file is deleted first, and then the file name of the temporary synchronous file is modified, so that file name conflict can be avoided, errors caused by inconsistent file names or file versions are reduced, and the integrity and consistency of file synchronization are guaranteed.
With reference to the first aspect, in some implementations of the first aspect, generating the temporary synchronization file according to the file to be synchronized includes performing incremental synchronization on the local file and the file to be synchronized to generate the temporary synchronization file.
In the implementation mode, the multi-terminal synchronization of the file is completed in an incremental synchronization mode, so that the data volume of file transmission can be effectively reduced, and the bandwidth is saved. And the data volume of transmission is reduced, so that the file synchronization process is quickened, and the overall data synchronization efficiency is improved. Meanwhile, the electronic equipment only needs to process the changed files, so that the load in the file synchronization process is effectively reduced, and the power consumption of the electronic equipment is reduced.
With reference to the first aspect, in some implementation manners of the first aspect, before acquiring the file to be synchronized sent by the at least one trusted electronic device, the file synchronization method may further include acquiring local metadata, comparing whether the local metadata is consistent with source metadata when the local metadata is detected to match the local file, and updating the local file when the local metadata is consistent with the source metadata.
The local metadata is used to describe the name, file size, file creation time, file last modification time, file last access time, file type, file authority (such as read-write authority, execution authority, etc.), file owner, file attribute flag (such as a specific flag bit, which is used to indicate that the file belongs to a hidden file, or a system file, or a read-only file, etc.), file system information, file version, file extension attribute (such as a custom tag), relative path, etc.
The source metadata is used to describe the name of the file to be synchronized, the file size, the file creation time, the file last modification time, the file last access time, the file type, the file rights (such as read-write rights, execution rights, etc.), the file owner, the file attribute flags (such as specific flag bits used to indicate that the file belongs to a hidden file, or a system file, or a read-only file, etc.), the file system information, the file version, the file extension attributes (such as custom tags), the relative path, etc.
In the implementation mode, the local metadata and the local file, and the local metadata and the source metadata are checked, and when the verification is passed, the subsequent file synchronization flow is executed, so that the accuracy of the subsequent file synchronization result can be ensured.
With reference to the first aspect, in some implementations of the first aspect, after comparing whether the local metadata is consistent with the source metadata when the local metadata is detected to be matched with the local file, the file synchronization method may further include determining difference data between the local metadata and the source metadata when the local metadata is inconsistent with the source metadata, and transmitting the difference data to at least one trusted electronic device.
The difference data is used for triggering at least one trusted electronic device to send a file to be synchronized to the electronic device.
In the implementation mode, when the local file is determined to be different from the source file, the difference data is sent to the trusted electronic equipment, the trusted electronic equipment is triggered to send the file to be synchronized to the electronic equipment, and the guarantee is provided for achieving file synchronization.
With reference to the first aspect, in certain implementation manners of the first aspect, after determining the difference data between the local metadata and the source metadata when the local metadata is inconsistent with the source metadata, the file synchronization method may further include sending the source metadata and the difference data to at least one trusted electronic device.
The method comprises the steps of receiving source metadata from a trusted electronic device, sending the source metadata to the trusted electronic device to verify whether the source metadata is matched with a local file in the trusted electronic device, and sending difference data to trigger the trusted electronic device to send a file to be synchronized to the electronic device when the source metadata is matched with the local file in the trusted electronic device.
In the implementation mode, the source file and the metadata of the trusted electronic equipment are checked first, and the subsequent file synchronization flow is executed under the condition that the source file has no problem, so that the accuracy of the subsequent file synchronization result can be ensured.
In a second aspect, the application provides an electronic device comprising one or more processors, one or more memories, a module having a plurality of applications installed thereon, the memories storing one or more programs which, when executed by the processors, cause the electronic device to perform the method of the first aspect and any of its possible implementations.
In a third aspect, the application provides an apparatus for processing data, comprising means for performing any of the methods of the first aspect. The device may be a server, an electronic device, or a chip in the electronic device. The apparatus may include an input unit and a processing unit.
When the apparatus is an electronic device, the processing unit may be a processor and the input unit may be a communication interface; the electronic device may further comprise a memory for storing computer program code which, when executed by the processor, causes the electronic device to perform any of the methods of the first aspect.
When the apparatus is a chip in an electronic device, the processing unit may be a processing unit inside the chip, the input unit may be an output interface, a pin, a circuit, or the like, the chip may further include a memory, which may be a memory (e.g., a register, a cache, or the like) inside the chip, or a memory (e.g., a read-only memory, a random access memory, or the like) located outside the chip, and the memory is configured to store computer program code, where the processor executes the computer program code stored in the memory, to cause the chip to perform any one of the methods of the first aspect.
In a fourth aspect, the present application provides a chip comprising a processor. The processor is configured to read and execute a computer program stored in the memory to perform the method of the first aspect and any possible implementation thereof.
Optionally, the chip further comprises a memory, and the memory is connected with the processor through a circuit or a wire.
Optionally, the chip further comprises a communication interface.
In a fifth aspect, the present application provides a computer readable storage medium having stored therein a computer program which, when executed by a processor, causes the processor to perform the method of the first aspect and any possible implementation thereof.
In a sixth aspect, the application provides a computer program product comprising computer program code which, when run on an electronic device, causes the electronic device to perform the method of the first aspect and any possible implementation thereof.
The technical effects obtained by the second, third, fourth, fifth and sixth aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and are not described herein.
Drawings
FIG. 1 is a schematic diagram of a system architecture to which the file synchronization method according to the embodiment of the present application is applied;
FIG. 2 is a schematic diagram of another system architecture to which the file synchronization method according to the embodiment of the present application is applicable;
fig. 3 is a schematic diagram of an application scenario of file synchronization according to an embodiment of the present application;
FIG. 4 is a schematic diagram of external storage-based backup data according to an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating a process of backing up data according to an embodiment of the present application;
FIG. 6 is a schematic diagram illustrating a process of file synchronization according to an embodiment of the present application;
FIG. 7 is a flowchart of a file synchronization method according to an embodiment of the present application;
FIG. 8 is a schematic diagram of incremental synchronization according to an embodiment of the present application;
FIG. 9 is a flowchart of another file synchronization method according to an embodiment of the present application;
FIG. 10 is a flowchart of another file synchronization method according to an embodiment of the present application;
FIG. 11 is a flowchart of another file synchronization method according to an embodiment of the present application;
FIG. 12 is a flowchart of another file synchronization method according to an embodiment of the present application;
FIG. 13 is a flowchart of another file synchronization method according to an embodiment of the present application;
Fig. 14 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application;
fig. 15 is a schematic software structure of an electronic device according to an embodiment of the present application;
fig. 16 is a schematic structural diagram of a chip according to an embodiment of the present application.
Detailed Description
The technical scheme of the application will be described below with reference to the accompanying drawings.
In the description of the embodiments of the present application, unless otherwise indicated, "/" means or, for example, a/B may represent a or B, and "and/or" herein is merely an association relationship describing an association object, and means that there may be three relationships, for example, a and/or B, and that there may be three cases where a exists alone, while a and B exist together, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" means two or more than two.
The terms "first" and "second" are used below for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. In the description of the present embodiment, unless otherwise specified, the meaning of "plurality" is two or more.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
For a better understanding of the embodiments of the present application, some terms involved in the embodiments of the present application are explained first below to facilitate understanding by those skilled in the art.
1. Trust ring and trusted electronic device
And the two or more electronic devices establish trust relationship through trusted authentication to form a trust ring.
The electronic devices can be trusted and authenticated by any one of the following methods, a trust relationship is established, and a trust ring is formed, wherein 1) the same account number is respectively logged in two or more electronic devices, and the electronic devices under the same account number trust each other, so that the two or more electronic devices form the trust ring. For example, two mobile phones of the same user, or a mobile phone, a tablet computer, a notebook computer, a home storage device (Network Attached Storage, NAS) and the like of the same user can perform trusted authentication by logging in an account number of the user, and a trust relationship is established to form a trust ring. 2) And carrying out trusted authentication on two or more electronic devices through a private protocol, and establishing a trust relationship to form a trust ring. 3) And (3) performing trusted authentication on two or more electronic devices through logging in the cloud, and establishing a trust relationship to form a trust ring. It will be appreciated that the above several ways of constructing a trust ring are for illustration only and are not to be construed as limiting the application in any way.
Electronic equipment in the trust ring forms a local area network through near field communication, and data can be synchronized through the local area network, so that the coordination of the equipment is realized. In embodiments of the present application, synchronization of data includes, but is not limited to, file synchronization.
The electronic device in the trust ring that actively initiates the synchronization request may be referred to as a master device, and other electronic devices that mutually pass the trusted authentication with the master device and have a trust relationship are referred to as trusted electronic devices. For example, the mobile phone, the tablet computer and the notebook computer form a trust ring, the mobile phone actively initiates a synchronization request in the trust ring, and applies for synchronizing files in the mobile phone to the tablet computer and the notebook computer, so that the mobile phone is a main device, and the tablet computer and the notebook computer are trusted electronic devices.
2. Cross-end mount (mount) access file
The storage devices transfer, share, and access files between different operating systems and electronic devices.
3. Trust ring application
The trust ring application represents an application in an electronic device within the trust ring. The user can set functions such as file backup, file synchronization and the like through the trust ring application.
By way of example, trust ring applications may include file management applications, setup applications, near field transmission applications, gallery applications, third party file synchronization applications, multimedia applications, social applications, web applications, educational applications, and the like.
4. Software development kit (Software Development Kit SDK)
Typically refers to a collection of development tools by which a software engineer builds an application program for a particular software package, software framework, hardware platform, operating system, or the like. In other words, an SDK is a collection of related documents, paradigms, and tools that facilitate the development of a certain class of applications, which facilitates the creation of the applications through compilers, debuggers, software frameworks, and the like.
In an embodiment of the present application, the SDK may include a file synchronization SDK. The file synchronization SDK may be integrated in an application program, such as in a trust ring application, thereby configuring the trust ring application with the capability of file synchronization.
5. Directory and folder
Directory and folder generally refer to the same concept, both being containers used to organize and store files and other directories/folders. In the embodiment of the application, the two words are used alternately in different application scenes, but the meaning and the function represented by the words are the same.
6. Water level synchronization
Water level synchronization is a concept in the field of real-time data processing that is used to ensure consistency and integrity of data in a distributed system. In the embodiment of the application, the water level synchronization is used for ensuring the consistency and the integrity of files in different electronic devices and different operating systems.
7. Incremental synchronization (INCREMENTAL SYNCHRONIZATION)
Incremental synchronization is a file synchronization technique that focuses on synchronizing only files that have changed since the last file synchronization.
The foregoing is a simplified description of the terminology involved in the embodiments of the present application, and is not described in detail below.
Electronic equipment in the trust ring forms a local area network through near field communication, and data can be synchronized through the local area network. For example, file synchronization may be performed between electronic devices within a trust ring.
Referring to fig. 1, fig. 1 is a schematic diagram of a system architecture to which a file synchronization method according to an embodiment of the present application is applicable. As shown in fig. 1, the electronic device 100, the electronic device 200, and the electronic device 300 establish a trust relationship through trusted authentication, and form a trust ring. It should be understood that the number of electronic devices included in the trust ring may be greater or less than the number of electronic devices shown in fig. 1, which is not limited in terms of practical requirements.
In an embodiment of the present application, electronic device 100, electronic device 200, and electronic device 300 may be a master device and a trusted electronic device with respect to each other.
Taking the electronic device 100 as a mobile phone, the electronic device 200 as a tablet computer, and the electronic device 300 as a notebook computer as an example. For example, when the mobile phone initiates a synchronization request to the tablet computer and the notebook computer, and applies for synchronizing files in the mobile phone to the tablet computer and the notebook computer, the mobile phone is a master device, and the tablet computer and the notebook computer are trusted electronic devices. For another example, when the mobile phone and the tablet computer initiate a synchronization request to the notebook computer, and the file in the mobile phone and the tablet computer is applied to be synchronized to the notebook computer, the mobile phone and the tablet computer are the main devices, and the notebook computer is the trusted electronic device. This is merely illustrative and is not limiting.
Referring to fig. 2, fig. 2 is a schematic diagram of another system architecture to which the file synchronization method according to the embodiment of the present application is applicable. As shown in fig. 2, the electronic device 100, the electronic device 200, and the electronic device 400 establish a trust relationship through trusted authentication, and form a trust ring. Unlike the trust ring shown in fig. 1, the trust ring shown in fig. 2 may include an electronic device 400 that is a NAS. In the embodiment of the application, the mobile phone and/or the tablet computer initiates a synchronization request to the NAS, and applies for synchronizing files in the mobile phone and/or the tablet computer to the NAS. The NAS may also perform cross-end mount access to files, for example, the NAS may transmit and share files to and may access files in the mobile phone and/or the tablet computer.
An application scenario of data synchronization between electronic devices in a trust ring is described below with reference to the accompanying drawings.
The trust ring provided by the embodiment of the application can comprise a mobile phone and an NAS, and is exemplified by synchronizing files in the mobile phone to the NAS.
Referring to fig. 3, fig. 3 is a schematic diagram of an application scenario of file synchronization according to an embodiment of the present application.
Illustratively, a setting application in the mobile phone is opened, a "system and update" option is selected in a display interface corresponding to the setting application, and the mobile phone displays an interface as shown in (a) of fig. 3. Clicking on control 101 in the interface shown in fig. 3 (a), i.e., clicking on the "backup and restore" option, the handset displays the interface shown in fig. 3 (b).
In the interface shown in fig. 3 (b), various data backup and restoration modes, such as cloud backup, external storage, mobile phone assistant, and the like, are displayed. The cloud backup can be used for backing up the whole machine data of the mobile phone to the cloud server, and if necessary, the whole machine data stored in the cloud server can be restored to the mobile phone through the cloud backup. The overall machine data may include gallery, contacts, text messages, call records, memos, input methods, harassment interception, wireless local area network (wireless local area networks, WLAN) settings, contextual smarts, cell phone households, clocks, weather, cameras, calendars, desktop icon layouts, system settings, applications, chat records, browsing records, and the like.
The external storage is used for connecting with an external storage device to backup and restore data. The external storage devices may include external memory cards, universal serial bus (Universal Serial Bus, USB) storage devices, NAS, and the like.
The mobile phone assistant is used for connecting the computer to backup and restore data.
In the embodiment of the application, the files in the mobile phone are backed up to the NAS in an external storage mode. It should be noted that synchronization also belongs to a backup method, and in the present application, the file in the mobile phone is also called as synchronizing to the NAS. In addition, it should be further noted that the files and data in the present application refer to the same content, that is, the files in the mobile phone may include gallery, contact, sms, call record, memo, input method, harassment interception, wireless local area network (wireless local area networks, WLAN) setting, scenario smart, mobile phone manager, clock, weather, camera, calendar, desktop icon layout, system setting, application, chat record, browsing record, etc.
Referring to fig. 4 and fig. 5, fig. 4 is a schematic diagram of an embodiment of the application, in which backup data is based on external storage, and fig. 5 is a schematic diagram of a backup data process according to an embodiment of the application.
Illustratively, clicking on control 102 in the interface shown in fig. 3 (b), i.e., clicking on the "external store" option, the handset displays the interface shown in fig. 4 (a). In the interface shown in fig. 4 (a), identification information corresponding to various external storage devices, such as an external memory card, USB storage, shared folder, etc., is displayed. The external memory card is used for backing up data in the mobile phone to the external memory card when the external memory card is detected, the USB memory is used for backing up the data in the mobile phone to the USB when the USB memory is connected to the USB, and the shared folder is used for backing up the data in the mobile phone to the home NAS device when the shared folder in the same network is found by scanning.
In this example, the shared folder is used to backup the data in the handset to the NAS. Illustratively, clicking on control 103 in the interface shown in fig. 4 (a), i.e., clicking on the "shared folder" option, the handset displays the interface shown in fig. 4 (b). At this time, the mobile phone finds out NAS storage devices in the same network through WLAN scanning, or the mobile phone finds out NAS storage devices in a trust ring, and after the NAS storage devices appear, the user can click to access and add a shared folder under the NAS storage devices.
Illustratively, clicking on control 104 in the interface shown in fig. 4 (c), i.e., clicking on the "device name" option, the handset displays the interface shown in fig. 5 (a). In the interface shown in fig. 5 (a), the device names of NAS storage devices are displayed, the storage space that the NAS storage devices have used (1.58 TB has been used) and the total storage space (e.g., 3.92 TB).
In the interface shown in fig. 5 (a), an automatic backup control 105, a switch control 106, and a select backup data item control 107 are also displayed. The switch control 106 is used to turn on the automatic backup function or turn off the automatic backup function, and fig. 5 (a) shows a scenario of turning on the automatic backup function.
For example, in the case where the automatic backup function is turned on, the user may set the period of automatic backup according to the need. For example, the mobile phone is automatically backed up every other day when the mobile phone is off, and the mobile phone is automatically backed up every seven days when the mobile phone is off.
Selecting the backup data item control 107 is used by the user to select the data item that needs to be backed up. Illustratively, clicking on the select backup data item control 107 in the interface shown in fig. 5 (a), i.e., clicking on the "auto backup data item" option, the handset displays the interface shown in fig. 5 (b).
In the interface shown in fig. 5 (b), a full selection control 108 and a start backup control 109 are displayed. The full selection control 108 is checked, and all data items to be backed up can be selected by one key, for example, data items such as music, pictures, videos, contacts, documents, system settings and the like shown in (b) in fig. 5 are selected by one key. It should be understood that this is merely illustrative, and that a user may also sort one or more data items that need to be backed up according to his/her needs.
After selecting the data item to be backed up, click on the start backup control 109 in the interface shown in fig. 5 (b), i.e. click on the "start backup" option, the handset displays the interface shown in fig. 5 (c). The mobile phone performs preparation data processing, such as calculating the number of items and the data size corresponding to each data item to be backed up, and displays the calculated items and the data size in an interface as shown in fig. 5 (c). After the data is ready, the mobile phone starts to backup the data, namely, the data items selected by the user in the mobile phone are backed up to the NAS, or, each file selected by the user in the mobile phone is synchronized to the NAS.
In the embodiment of the application, the distributed management service is adopted to manage each electronic device in the trust ring, so that data can be stored and accessed among different electronic devices (such as mobile phones, tablet computers, notebook computers, NAS (network attached storage) and the like), different operating systems (such as Android systems, IOS operating systems, sambur (Symbian) operating systems, blackberry (blackberry) operating systems, linux operating systems, windows operating systems and the like), and data storage and access among cross-device and cross-system data are realized, so that a data access channel of near-field communication among the electronic devices is opened.
The application scenario of file synchronization is described above in connection with user operation, and the specific process of file synchronization between electronic devices in a trust ring is described below in connection with the accompanying drawings.
The trust ring provided by the embodiment of the application can comprise a mobile phone and a personal computer (Personal Computer, PC), and the PC can comprise a desktop computer, a notebook computer, a small notebook computer, a tablet personal computer, an ultrabook and the like, so that the file in the mobile phone is synchronized into the tablet personal computer for illustration.
Referring to fig. 6, fig. 6 is a schematic diagram illustrating a file synchronization process according to an embodiment of the application.
S101, the trust ring application acquires a file synchronization request and invokes a file synchronization SDK.
The trust ring application represents an application in an electronic device within the trust ring. The user can set functions such as file backup starting, file synchronization and the like through the trust ring application, or functions such as file backup closing, file synchronization and the like.
In the embodiment of the application, the trust ring application can comprise a file management application, a setting application, a near field transmission application, a gallery application, a third party file synchronization application, a multimedia application, a social application, a network application, an education application and the like.
The file synchronization SDK is pre-integrated in the trust ring application, so that the trust ring application can conveniently create a shared directory/shared folder by calling the file synchronization SDK.
The file synchronization request is used for requesting to synchronize a file in an electronic device to which the trust ring application belongs to at least one trusted electronic device that the trust ring also comprises. For example, the electronic device to which the trust ring application belongs is a mobile phone, the trusted electronic device that the trust ring further includes is a tablet computer, and the file synchronization request is used for requesting to synchronize a file in the mobile phone to the tablet computer.
The file synchronization request may be triggered by the electronic device to which the trust ring application belongs, or may be triggered by the trusted electronic device. Illustratively, the trust ring application installed on the mobile phone receives an operation that a user sets to start a file synchronization function, and triggers a file synchronization request. Or the trusted electronic device initiates a file synchronization request to the electronic device to which the trust ring application belongs, the electronic device to which the trust ring application belongs receives the file synchronization request, for example, the tablet computer initiates the file synchronization request to the mobile phone, and the mobile phone receives the file synchronization request.
Illustratively, when the trust ring application obtains the file synchronization request, the file synchronization SDK is invoked by pre-written code in the trust ring application.
S102, the file synchronization SDK calls a file synchronization service module to create a shared directory/shared folder.
Illustratively, the file synchronization service module is deployed at the application framework layer, and is a software component specifically designed in the present application to synchronize files between different electronic devices and different operating systems.
In an embodiment of the present application, the shared directory may be represented by a REPO directory, which may be shared by electronic devices within the trust ring. The REPO directory may include information such as a file path, a scan start time, a scan time interval, REPO identification information, an electronic device name, file synchronization configuration information, a callback function of the file path, and the like.
The file path refers to a path corresponding to the file to be synchronized, that is, a path where the file to be synchronized to the trusted electronic device is located. For example, the user wants to synchronize the pictures on the mobile phone to the tablet computer, and selects a path corresponding to the gallery on the mobile phone, or selects a directory corresponding to the gallery on the mobile phone, where the selected path or the selected directory is a file path.
The scan start time is the time when the electronic device starts scanning the file path. The time when the electronic device starts scanning the file path for the first time is generally determined according to the time when the user sets the file synchronization function to be started for the first time. For example, when the user selects to immediately start synchronizing the file when the user first sets to start the file synchronization function, the electronic device immediately starts scanning the file path, that is, the scanning start time is the time when the user starts to start the file synchronization function.
The time when the electronic device starts scanning the file path for the non-first time is determined according to the file synchronization period set by the user, i.e. according to the scanning time interval. For example, the user sets to automatically synchronize a file once every other day, or automatically synchronize a file once every seven days, or the like, then the electronic device scans a file path once every other day, or scans a file path once every seven days, or the like, after scanning the file path for the first time.
The REPO identification information is an Identifier (ID) of the REPO for uniquely identifying the REPO of the electronic device.
The file synchronization configuration information may include a number of file syncs, a version of the file syncs, a name of the trusted electronic device, REPO identification information of the trusted electronic device, a file path of the trusted electronic device, a filter file, and the like.
Wherein the file synchronization version is used to indicate that the synchronized file has changed. For example, when the file is synchronized for the first time, the file synchronization version is recorded to be 1.0, when the file is changed for the second time, the file synchronization version is recorded to be 1.1, and when the file is changed for the third time, the file synchronization version is recorded to be 1.2.
The REPO identification information of the trusted electronic device, i.e. the ID of the REPO of the trusted electronic device, is used to uniquely identify the REPO of the trusted electronic device. For example, when the REPO identification information of the mobile phone matches the REPO identification information of the tablet computer, the mobile phone and the tablet computer may perform file synchronization.
The file path of the trusted electronic device refers to a path for storing files to be synchronized, i.e. a path for storing files synchronized in the electronic device. For example, the user wants to synchronize the picture on the mobile phone to a specific path in the tablet computer, where the specific path is a file path of the trusted electronic device.
Filtering files refers to files that do not use synchronization. In the embodiment of the application, the file is not scanned and filtered, so that the power consumption of the electronic equipment can be reduced, the time for scanning the file in the file synchronization process is effectively reduced, and the file synchronization efficiency is improved.
Illustratively, the file synchronization SDK invokes the file synchronization service module to cause the file synchronization service module to create a shared directory/shared folder, such as to create a REPO directory, using an application programming interface (Application Programming Interface, API) function or method provided by the file synchronization SDK.
S103, the file synchronization service module performs data persistence processing on the shared directory/shared folder.
Data persistence refers to the long-term storage of data on a persistable storage medium so that the data may still be accessed after an application or operating system reboots.
In the embodiment of the application, the REPO catalog can be stored in the local database of the mobile phone which can be stored permanently, so that after the user sets the file synchronization function, even if the mobile phone is restarted or the trust ring application is restarted, the related information of the file synchronization function set by the user can be read from the local database, and the related information of the REPO catalog is ensured not to be lost. For the user, the related information of the file synchronization function is only required to be set once, so that the user can always apply the file synchronization function without resetting the related information of the file synchronization function after the mobile phone is restarted or the trust ring application is restarted each time, and the user experience is improved.
In the above steps S101 to S103, the electronic device (e.g. mobile phone) creates a shared directory/shared folder, such as a scenario of creating a REPO directory, when acquiring the file synchronization request. In one possible implementation, the electronic device (e.g., a cell phone) may also pre-create the shared directory/shared folder, such as pre-creating the REPO directory, i.e., the electronic device (e.g., a cell phone) creates the REPO directory before acquiring the file synchronization request. For example, the trust ring application invokes a file synchronization SDK that invokes a file synchronization service module to create a REPO directory, which performs data persistence processing on the REPO directory.
The method for creating the REPO catalog in the electronic equipment in advance is beneficial to the electronic equipment in the follow-up trust ring to directly utilize the REPO catalog for file synchronization, and improves the efficiency of file synchronization.
Alternatively, in one possible implementation, the trusted electronic device may create a shared directory/shared folder, such as a REPO directory, using a method similar to that described above in steps S101 through S103. As shown in fig. 6, the method specifically includes:
s201, a trust ring application in the trusted electronic equipment acquires a file synchronization request and invokes a file synchronization SDK.
S202, the file synchronization SDK calls a file synchronization service module in the trusted electronic device, and a shared directory/shared folder is created.
S203, the file synchronization service module performs data persistence processing on the shared directory/shared folder.
For the description of step S201 to step S203, reference may be made to the specific description of step S101 to step S103, which is not repeated here.
The trusted electronic device (e.g., tablet computer) creates a shared directory/shared folder, such as a scene of creating a REPO directory, when acquiring the file synchronization request in steps S201 to S203. In one possible implementation, the trusted electronic device (e.g., tablet) may also pre-create the shared directory/shared folder, such as pre-creating the REPO directory, i.e., the trusted electronic device (e.g., tablet) creates the REPO directory before acquiring the file synchronization request.
The method for creating the REPO catalog in the trusted electronic equipment in advance is beneficial to the electronic equipment in the subsequent trust ring to directly utilize the REPO catalog for file synchronization, and improves the efficiency of file synchronization.
S104, sharing the REPO directory with the trusted electronic device.
For example, the electronic device (such as a mobile phone) determines a file to be synchronized according to the file synchronization request, scans a file path in the electronic device (such as the mobile phone) based on the file to be synchronized, and records a file synchronization version for each scanning result.
For example, a first scan of a file path in an electronic device (e.g., a mobile phone) based on a file to be synchronized records a file synchronization version 1.0 for a first scan result, a second scan of a file path in an electronic device (e.g., a mobile phone) based on a file to be synchronized detects a change in the file to be synchronized compared with the first scan result, records a file synchronization version 1.1 for a second scan result, a third scan of a file path in an electronic device (e.g., a mobile phone) based on a file to be synchronized detects no change in the file to be synchronized compared with the second scan result, records a file synchronization version 1.1 for a third scan result, and so on.
The electronic device (e.g., a cell phone) shares the synchronized version of the file recorded each time with a trusted electronic device (e.g., a tablet computer). For example, the electronic device (e.g., a mobile phone) records the file synchronization version recorded each time in the REPO directory and shares the file synchronization version with the trusted electronic device (e.g., a tablet computer), and the trusted electronic device (e.g., the tablet computer) shares changes that can be read from the REPO directory to the file synchronization version, thereby quickly determining changes in the synchronized file.
S105, the REPO catalog metadata synchronization processing is carried out with the trusted electronic equipment.
Metadata (Metadata) is used to describe data attributes, and the REPO directory Metadata refers to information such as a file path, a scan start time, a scan time interval, REPO identification information, an electronic device name, and file synchronization configuration information included in the REPO directory.
REPO directory metadata synchronization is understood to mean that an electronic device (e.g., a cell phone) and a trusted electronic device (e.g., a tablet computer) are level synchronized based on REPO directories. For example, the electronic device (such as a mobile phone) synchronizes the information including the file path, the scanning start time, the scanning time interval, the REPO identification information, the electronic device name, the file synchronization configuration information and the like in the REPO catalog with the trusted electronic device (such as a tablet computer), so as to provide guarantee for consistency and integrity of the subsequent files in different electronic devices and different operating systems.
S106, the file synchronization service module monitors a file system.
The file synchronization service module may include a listening scan management module for listening, scanning a file system in an electronic device (e.g., a cell phone).
The mobile phone determines the file to be synchronized according to the file synchronization request, monitors and scans the file path of the file to be synchronized in the file system. For example, the user wants to synchronize the pictures on the mobile phone to the tablet computer, and monitors and scans the path corresponding to the gallery on the mobile phone.
When the monitored and scanned file to be synchronized changes, if the monitored and scanned file to be synchronized changes such as new addition, deletion, modification and the like, the file synchronization service module is notified of the changes.
For example, the file to be synchronized is a picture, and a picture discovery change in any application program related to the picture affects the file to be synchronized. Such as camera applications, social applications, sharing applications, etc., and/or delete and/or modify pictures, and notify the file synchronization service module of the corresponding changes.
The file synchronization service module generates a file change record according to the change of the file, and performs data persistence processing on the file change record. The file change record may include operations such as adding, deleting, modifying, etc. to the file, and operation times corresponding to the respective operations.
The file change record is illustratively stored in a local database of the handset that is persistable so that it can be read from the local database even if the handset is restarted, or the trust ring application is restarted, or any application associated with the file to be synchronized is restarted.
S107, the file synchronization service module reads the file change record from the local database.
The file synchronization service module periodically reads file change records from the local database according to a file synchronization period set by a user. For example, the file synchronization service module reads a file change record from the local database every time the electronic device listens to, scans the file system.
S108, carrying out file metadata synchronization processing with the trusted electronic equipment.
The file metadata refers to information such as file name, electronic device to which the file belongs, file size, file addition time, file deletion time, file modification time, and the like.
File metadata synchronization is understood to mean that an electronic device (e.g., a cell phone) synchronizes file metadata with a trusted electronic device (e.g., a tablet computer). In the implementation mode, the file metadata is firstly synchronized with the trusted electronic equipment, and then the file content can be directly synchronized, so that the file synchronization efficiency is improved, and errors are not easy to occur.
It should be understood that, the electronic device performs file metadata synchronization processing with the trusted electronic device, and after the electronic device sends the file metadata to the trusted electronic device, the trusted electronic device needs to compare the file metadata sent by the electronic device with the file metadata of the trusted electronic device. As shown in fig. 6, the comparison method specifically includes:
s204, the trusted electronic equipment performs file metadata comparison processing.
The alignment process (Comparison Processing) is a data analysis technique for identifying differences and similarities between file metadata sent by an electronic device and file metadata of a trusted electronic device.
For example, the tablet computer compares the file metadata in its own file system with the file metadata sent by the mobile phone one by using the file synchronization service module. If the comparison result is inconsistent, the file metadata sent by the mobile phone is used as the reference, namely the file metadata in the tablet computer is modified into the file metadata sent by the mobile phone.
In the implementation mode, the file metadata in the electronic equipment and the file metadata in the trusted electronic equipment are synchronized, and then the file contents can be directly synchronized, so that the file synchronization efficiency is improved, and errors are not easy to occur.
Optionally, in one possible implementation, after the trusted electronic device performs the file metadata comparison process, the data persistence process is performed on the file metadata sent by the electronic device. For example, the modified file metadata is stored in a local database.
And S109, performing file content synchronization processing with the trusted electronic equipment.
The file content refers to the file itself. For example, if the file to be synchronized is a picture, the file content is the picture itself, and if the file to be synchronized is music, the file content is the audio itself.
The file synchronization service module in the electronic device, for example, reads file content from the file system and sends the read file content to the trusted electronic device. Accordingly, the trusted electronic device needs to save the file content sent by the electronic device. As shown in fig. 6, the preservation method specifically includes:
S205, the trusted electronic equipment performs file disc dropping processing on the file content.
File dropping generally refers to writing data from a temporary storage area to a permanent storage device. In the embodiment of the application, the trusted electronic equipment stores the file content sent by the electronic equipment into a local database of the trusted electronic equipment. Optionally, in one possible implementation, the trusted electronic device saves the file content sent by the electronic device to a file system, and saves the file content in the file system to a local database. Thus, even if the trusted electronic device is restarted or the trust ring application is restarted, the synchronized file is not affected, and the synchronized file can still be read from the local database.
It should be noted that, when describing the specific process of file synchronization between electronic devices in the trust ring, the description is given taking the example of synchronizing the files in the mobile phone to the tablet computer, so the method executed by the mobile phone side is mainly described. It can be understood that when the file in the tablet computer needs to be synchronized to the mobile phone, the tablet computer can execute the steps executed by the mobile phone, and the mobile phone can execute the steps executed by the tablet computer.
It can be appreciated that, in the embodiment of the present application, the Android operating system is taken as an example for illustration, but the basic principles are equally applicable to electronic devices based on the IOS, symbian, black Berry, linux, windows and other operating systems.
In the embodiment of the application, the file synchronization SDK integrated in the trust ring application configures the file synchronization capability for the trust ring application, and the file synchronization service module provides core service for file synchronization between electronic devices in the trust ring. Illustratively, the file synchronization service module completes sensing of file changes and generation of file metadata by listening and scanning the local file system. Meanwhile, the trust ring self-discovery and self-networking capability provided by the system can enable the electronic equipment to quickly discover the peripheral equipment, so that REPO catalog sharing, REPO metadata synchronization, file metadata synchronization and file content synchronization of the electronic equipment and the trusted electronic equipment in the trust ring are realized, cross-equipment and cross-system data storage and access are realized, and a data access channel of near field communication between the electronic equipment is opened.
In the related art, when file synchronization is performed between electronic devices in a trust ring, the synchronized files cannot be checked, so that inconsistency between the synchronized files and source files can occur, and the integrity of file synchronization is affected. If the synchronized file is tampered, security risks are brought to the electronic equipment in the trust ring, so that the whole file synchronization process is unsafe and is easy to make mistakes.
For example, pictures in a trusted electronic device are synchronized into the electronic device, and the environment for default file synchronization is safe and trusted, so that the synchronized pictures are not verified, considering that the electronic device and the trusted electronic device are within the same trust ring. The trusted electronic device directly sends the picture to the electronic device, and the electronic device receives the picture and stores the picture in the file system, so that the picture synchronized by the electronic device is inconsistent with the picture in the trusted electronic device, and the integrity of file synchronization is affected. If the synchronized picture is tampered with, it may result in the system of the electronic device and the trusted electronic device being attacked by malware or viruses. If the synchronization process is wrong, the synchronized pictures are damaged, lost and the like. It can be seen that the file synchronization process in the related art is not secure and is very prone to error.
In view of the above, the embodiment of the application provides a file synchronization method, which is applied to electronic equipment, wherein a trust ring where the electronic equipment is located also comprises at least one trusted electronic equipment, and the method comprises the steps of obtaining a file to be synchronized sent by the at least one trusted electronic equipment; generating a temporary synchronous file according to the file to be synchronized, checking the temporary synchronous file, and synchronizing the temporary synchronous file into a file system when the temporary synchronous file passes the check.
In the implementation mode, when the file to be synchronized sent by the trusted electronic equipment is obtained, the file to be synchronized is not directly stored in the file system, but the temporary synchronization file is generated according to the file to be synchronized, the temporary synchronization file is checked, and when the temporary synchronization file passes the check, the temporary synchronization file is synchronized into the file system. The temporary synchronous file is checked, so that the file received by the electronic equipment is consistent with the source file, the integrity of file synchronization is ensured, and the accuracy of file synchronization is improved. The temporary synchronous file is checked, so that the synchronous file is not tampered, the system of the electronic equipment in the trust ring is prevented from being attacked by malicious software or viruses, and the safety of the file synchronization process is improved.
The file synchronization method provided by the embodiment of the application is described below with reference to a flowchart.
Referring to fig. 7, fig. 7 is a flowchart illustrating a file synchronization method according to an embodiment of the application. The method comprises the following steps:
s301, acquiring a file to be synchronized sent by at least one trusted electronic device.
And the two or more electronic devices establish trust relationship through trusted authentication to form a trust ring. In the embodiment of the application, the trust ring where the electronic device is located also comprises at least one trusted electronic device, and the file in the electronic device can be synchronized into the trusted electronic device in the trust ring.
In one example, a trusted electronic device triggers a file synchronization request that instructs the trusted electronic device to send a file to be synchronized (i.e., a file that is to be synchronized) to the electronic device, and the electronic device receives the file to be synchronized sent by the trusted electronic device. For example, the user wants to synchronize the picture on the trusted electronic device (such as a mobile phone) to the electronic device (such as a tablet computer), selects a "start synchronization" option after selecting the picture in the gallery through a trust ring application installed on the mobile phone, triggers a file synchronization request, the mobile phone sends the selected picture to the tablet computer, and the tablet computer receives the picture sent by the mobile phone. The picture is the file to be synchronized.
In another example, the electronic device triggers a file synchronization request for requesting the trusted electronic device to send a file to be synchronized to the electronic device, the electronic device receiving the file to be synchronized sent by the trusted electronic device. For example, a user wants to synchronize a picture on a trusted electronic device (such as a mobile phone) to the electronic device (such as a tablet computer), the tablet computer initiates a file synchronization request to the mobile phone, the file synchronization request carries indication information of the picture to be synchronized, the mobile phone receives the file synchronization request, and sends the picture to the tablet computer according to the indication information of the picture, and the tablet computer receives the picture sent by the mobile phone.
It can be appreciated that when the user selects a picture in the gallery, the storage location in the tablet computer where the picture is stored may also be specified.
Alternatively, in one possible implementation, the file synchronization request may be triggered automatically by the trusted electronic device. For example, the user sets to automatically synchronize the file once every other day, or automatically synchronize the file once every seven days, etc., and then the mobile phone automatically triggers a file synchronization request once every other day after the file is first synchronized. For another example, when the user sets time to reach a preset time point (such as 8-point integer, 12-point integer, 23-point integer, etc.), the mobile phone automatically triggers a file synchronization request when the mobile phone detects that the current time reaches the preset time point. This is merely an exemplary illustration and is not limiting in this regard.
Optionally, in another possible implementation manner, the electronic device in the trust ring may also automatically trigger the file synchronization request, and send the file synchronization request to the trusted electronic device after each triggering, which will be described in detail herein.
S302, generating a temporary synchronous file according to the file to be synchronized.
The file to be synchronized is the file to be synchronized. In the embodiment of the application, the file to be synchronized can be a file for synchronization, which is sent by the trusted electronic device to the electronic device. For example, if a user wants to synchronize a picture on a trusted electronic device (such as a mobile phone) to an electronic device (such as a tablet computer), the picture sent by the mobile phone to the tablet computer is a file to be synchronized.
In one possible implementation, the temporary synchronization file is generated directly from the file to be synchronized. Illustratively, a full-scale synchronization mode is adopted to generate a temporary synchronization file according to the file to be synchronized. For example, a temporary storage location is created, the files to be synchronized are all copied into the temporary storage location, and the files to be synchronized stored in the temporary storage location are determined to be temporary synchronization files. Wherein the temporary storage location may comprise a REPO directory.
In another possible implementation manner, a local file corresponding to the file to be synchronized is obtained in a file system of the electronic device, and a temporary synchronization file is generated according to the local file and the file to be synchronized.
The local file refers to a file stored in a designated storage location by the electronic device prior to synchronizing the file to be synchronized. The designated storage location is used for storing the file to be synchronized. It is understood that the storage location of the local file in the electronic device coincides with the storage location of the file to be synchronized in the electronic device.
For example, when a user selects a file to be synchronized (such as a picture in a gallery) on a mobile phone, a storage position of the picture stored in the tablet computer is designated as a D disc, and before the file to be synchronized is synchronized, the file stored in the D disc is a local file.
S303, checking the temporary synchronous file.
Illustratively, verifying the temporary synchronization file may include verifying the integrity of the temporary synchronization file, the consistency of the temporary synchronization file with the source file, whether the temporary synchronization file functions properly, and the like.
The integrity of the temporary synchronous file and the consistency of the temporary synchronous file and the source file are checked, so that the file to be synchronized is not damaged or changed in the transmission process, and the safety of the file synchronization process can be improved.
In the embodiment of the application, the integrity of the temporary synchronous file and the consistency of the temporary synchronous file and the source file can be checked by hash check, file check sum, digital signature, file content comparison, and the like.
In the embodiment of the application, the hash check is taken as an example for explanation. For example, a source file corresponding to the temporary synchronization file is acquired, a hash value of the temporary synchronization file is calculated, and the hash value of the source file is compared with whether the hash value of the temporary synchronization file is identical with the hash value of the source file. When the hash value of the temporary synchronous file is consistent with the hash value of the source file, determining that the temporary synchronous file is complete, namely that the integrity of the temporary synchronous file is not problematic, and simultaneously determining to check the consistency of the temporary synchronous file and the source file.
Illustratively, the hash values of the temporary synchronization file and the source file may be calculated by an MD5 (MESSAGE DIGEST Algorithm 5) Algorithm, an SHA-1 (Secure Hash Algorithm 1) Algorithm, an SHA-2 (Secure Hash Algorithm 2) Algorithm, or the like.
Optionally, the integrity of the temporary synchronization file may also be verified by a verification tool (e.g., md5sum, sha1sum, sha256sum, etc.).
The file checksum is a method similar to hash checking. In an embodiment of the present application, the checksum of the temporary synchronization file may be calculated by a command line tool, such as a (cksum command), by which the integrity of the temporary synchronization file and the consistency of the temporary synchronization file with the source file are verified.
Alternatively, when the temporary synchronization file is a compressed file, the integrity of the compressed file may be verified using a decompression tool corresponding to the compression tool. It will be appreciated that the decompression operation will verify the file when it is decompressed, and that the decompression process will fail if the temporary synchronization file is damaged or incomplete.
Alternatively, when the temporary synchronization file is a text file or a data file, the file content comparison may be directly performed to check whether the content of the source file and the temporary synchronization file are identical. For example, a script (e.g., python script, powerShell script) or the like is used to automatically check whether the list and number of files in the temporary synchronization file are consistent with the list and number of files in the source file. When the list and number of files in the temporary synchronization file are consistent with the list and number of files in the source file, determining the integrity of the temporary synchronization file is not problematic, while determining to verify the consistency of the temporary synchronization file with the source file.
Alternatively, when the temporary synchronization file is a binary file, the file content comparison may be performed by a file comparison tool (e.g., diff tool), and it is checked whether the contents of the source file and the temporary synchronization file are identical.
And whether the function of the temporary synchronous file is normal is checked, so that the temporary synchronous file can still work normally after synchronization, and the stability of file synchronization is improved. Illustratively, when the temporary synchronization file is an executable file or an application file, the temporary synchronization file is functionally tested. For example, running the temporary synchronization file and checking the running output result, opening the temporary synchronization file, checking whether the file content is correctly displayed, etc.
S304, synchronizing the temporary synchronous file into the file system when the temporary synchronous file passes the verification.
Illustratively, when the temporary synchronization file passes verification, the temporary synchronization file is copied to a designated storage location in the file system using a preset copy command or copy tool.
In this implementation, the temporary synchronization file is copied to a designated storage location in the file system, where the temporary synchronization file may also be temporarily maintained, and when a write error or system failure occurs in the designated storage location, the temporary synchronization file in the temporary storage location may be used as a backup file to restore the file when needed. If errors are found during file synchronization, the temporary synchronization file in the temporary storage location may be used to verify and correct the errors, ensuring that the final synchronized file is accurate.
Optionally, when the temporary synchronization file passes the verification, the temporary synchronization file is moved to a designated storage location in the file system using a preset movement command or movement tool.
In the implementation mode, the temporary synchronous file is moved to the designated storage position in the file system, so that the temporary storage space is released in time, the system can conveniently continue to execute other file synchronous tasks or store new files, and the file synchronous efficiency is improved.
According to the file synchronization method provided by the embodiment of the application, when the file to be synchronized sent by the trusted electronic equipment is obtained, the file to be synchronized is not directly stored in the file system, but the temporary synchronization file is generated according to the file to be synchronized, the temporary synchronization file is checked, and when the temporary synchronization file is checked, the temporary synchronization file is synchronized into the file system. The temporary synchronous file is checked, so that the file received by the electronic equipment is consistent with the source file, the integrity and consistency of file synchronization are ensured, the finally synchronized file is accurate, and the accuracy of file synchronization is improved. The temporary synchronous file is checked, the synchronous file is not tampered, the error is not easy to occur in the synchronous process, the system of the electronic equipment in the trust ring is effectively prevented from being attacked by malicious software or viruses, and the safety of the file synchronous process is improved.
Optionally, in a possible implementation manner, the generating a temporary synchronization file according to the local file and the file to be synchronized in the step S302 may further include performing incremental synchronization on the local file and the file to be synchronized to generate the temporary synchronization file.
Illustratively, by comparing the difference between the local file and the file to be synchronized, a file that has changed since the last synchronization is determined, a temporary synchronization file is generated from the changed file, and the temporary synchronization file is stored in a temporary storage location. Or the changed file is moved or copied to a temporary storage location, and the changed file is recorded as a temporary synchronous file. And then, the temporary synchronous file is moved or copied from the temporary storage position to a designated storage position in the file system, so that the synchronization can be completed.
For example, a data block corresponding to a local file and a data block corresponding to a file to be synchronized are obtained. And comparing the data blocks of the local file with the data blocks of the file to be synchronized one by one, wherein the different data blocks are the data blocks corresponding to the changed file, generating the data blocks corresponding to the temporary synchronization file according to the different data blocks, and storing the data blocks corresponding to the temporary synchronization file in a temporary storage position. And then, the data blocks of the temporary synchronous file are moved or copied from the temporary storage position to the designated storage position in the file system, so that the synchronization can be completed.
Optionally, in order to increase the speed of comparing the local file with the file to be synchronized, thereby increasing the speed of generating the temporary synchronization file and further increasing the efficiency of file synchronization, the local metadata of the local file and the metadata of the file to be synchronized may be compared.
Illustratively, local metadata of a local file is obtained, as well as source metadata of a file to be synchronized. The difference between the local metadata and the source metadata is compared one by one. The local metadata is used to describe the name, file size, file creation time, file last modification time, file last access time, file type, file authority (such as read-write authority, execution authority, etc.), file owner, file attribute flag (such as a specific flag bit, which is used to indicate that the file belongs to a hidden file, or a system file, or a read-only file, etc.), file system information, file version, file extension attribute (such as a custom tag), relative path, etc. It should be appreciated that the source metadata is similar to the local metadata, except that the source metadata is used to describe the files to be synchronized and the local metadata is used to describe the local files.
For ease of understanding, please refer to fig. 8, fig. 8 is a schematic diagram illustrating incremental synchronization according to an embodiment of the present application.
As shown in fig. 8, the source metadata includes data block 1, data block 2, data block 3, data block 4, data block 5, and data block 6, the new file includes data block 1, data block 2, changed data block 1, data block 3, changed data block 2, data block 5, and changed data block 6, and the local metadata includes data block 1, data block 2, data block 3, data block 4, and data block 5.
Illustratively, the local metadata is compared with the first data block of the source metadata, namely, the data block 1 of the local metadata is compared with the data block 1 of the source metadata, and the comparison result is that the data block 1 of the local metadata is consistent with the data block 1 of the source metadata. That is, the file indicated by the data block 1 of the source metadata is unchanged from the file indicated by the data block 1 of the local metadata.
And comparing the local metadata with other data blocks of the source metadata in turn. The data block 2 of the source metadata is identical to the data block 2 of the local metadata. The data block 3 of the source metadata is newly added with the changed data block 1 in the new file as shown in fig. 8 before the data block 3 of the local metadata, and accordingly, the position of the data block 3 of the source metadata is shifted backward, and the data block 3 shown in fig. 8 is the shifted data block 3 of the local metadata. The data block 4 of the source metadata is deleted from the data block 4 of the local metadata, and the changed data block 2 in the new file shown in fig. 8 is newly added. The position of the source metadata data block 5 is shifted backward compared with the local metadata data block 5 due to the addition of the change data block 2, and the data 5 shown in fig. 8 is the shifted local metadata data block 5. The source metadata is also newly added with the change data block 3 in the new file as shown in fig. 8, compared to the local metadata.
As shown in fig. 8, the new file shows the difference between the source metadata and the local metadata, that is, the file changed since the last synchronization is determined, a temporary synchronization file can be generated according to the changed file, and the temporary synchronization file is stored in a temporary storage location, so that the temporary synchronization file can be conveniently synchronized into the file system of the electronic device.
The multi-terminal synchronization of the file is completed in an incremental synchronization mode, so that the data volume of file transmission can be effectively reduced, and the bandwidth is saved. And the data volume of transmission is reduced, so that the file synchronization process is quickened, and the overall data synchronization efficiency is improved. Meanwhile, the electronic equipment only needs to process the changed files, so that the load in the file synchronization process is effectively reduced, and the power consumption of the electronic equipment is reduced.
Alternatively, in one possible implementation, the corresponding embodiment of fig. 8 may also be implemented in a trusted electronic device. For example, the trusted electronic device compares metadata of the current file, that is, metadata of the source end with metadata corresponding to the file in the last synchronization, and through the difference between the metadata and the metadata, the file which changes since the last synchronization in the trusted electronic device can be determined, and a file to be synchronized can be generated according to the changed file, so that the file to be synchronized is conveniently sent to the electronic device, and file synchronization is achieved.
It should be noted that, in the implementation scenario of the electronic device or the implementation scenario of the trusted electronic device, when comparing the source metadata with the local metadata, each data block in the source metadata may be traversed in sequence with reference to determine whether each data block in the source metadata has a consistent data block in the local metadata, and if not, it is determined to be a changed data block. Or traversing each data block in the local metadata in turn by taking the source metadata as a reference, determining whether each data block in the local metadata has a consistent data block in the source metadata, and if not, determining the data block as a change data block.
Optionally, in a possible implementation manner, the step S303 may further include a step S3031 and a step S3033, which are specifically as follows.
Referring to fig. 9, fig. 9 is a flowchart illustrating another file synchronization method according to an embodiment of the application. The method comprises the following steps:
s3031, source end metadata sent by at least one trusted electronic device is obtained.
The source metadata is used to describe the name of the file to be synchronized, the file size, the file creation time, the file last modification time, the file last access time, the file type, the file rights (such as read-write rights, execution rights, etc.), the file owner, the file attribute flags (such as specific flag bits used to indicate that the file belongs to a hidden file, or a system file, or a read-only file, etc.), the file system information, the file version, the file extension attributes (such as custom tags), the relative path, etc.
In one example, the electronic device or trusted electronic device triggers a file synchronization request, the trusted electronic device carries source metadata in a file to be synchronized that is sent to the electronic device, and the electronic device extracts the source metadata from the file to be synchronized.
In another example, an electronic device sends a metadata acquisition request to a trusted electronic device, the metadata acquisition request to trigger the trusted electronic device to send source metadata to the electronic device, the electronic device receiving the source metadata sent by the trusted electronic device.
S3032, generating a check value corresponding to the temporary synchronous file and a check value corresponding to the source end metadata.
The check value of the temporary synchronization file and the check value of the source metadata may include a weak Hash value, a strong Hash value, a checksum, a Hash-based message authentication code (Hash-based Message Authentication Code, HMAC), and the like.
Illustratively, the hash value corresponding to the temporary synchronization file and the hash value corresponding to the source metadata may be calculated by an MD5 (MESSAGE DIGEST Algorithm 5) Algorithm, an SHA-1 (Secure Hash Algorithm 1) Algorithm, an SHA-2 (Secure Hash Algorithm 2) Algorithm, or the like.
The MD5 algorithm and the SHA-1 algorithm can be used for calculating weak hash values corresponding to the temporary synchronous file and weak hash values corresponding to the source metadata.
In the embodiment of the application, the check value of the metadata of the temporary synchronous file can be used for representing the check value of the temporary synchronous file. Illustratively, metadata of the temporary synchronization file is acquired, and a hash function corresponding to the MD5 algorithm is determined. Metadata of the temporary synchronization file is input into a hash function, and the hash function processes the metadata of the temporary synchronization file and outputs a weak hash value with a fixed length. Similarly, the source metadata is input into a hash function, which processes the source metadata and outputs a weak hash value of a fixed length.
In the implementation mode, the weak hash value is simple and efficient to calculate, so that the file synchronization efficiency can be improved under the condition that the file synchronization process is ensured, and the user experience is improved.
Optionally, the check value corresponding to the temporary synchronization file and the check value corresponding to the source end metadata may also be generated by a check tool (such as md5sum, sha1sum, sha256sum, etc.).
S3033, when the check value of the temporary synchronous file is detected to be consistent with the check value of the source end metadata, determining that the temporary synchronous file passes the check.
Illustratively, detecting that the check value of the temporary synchronization file is consistent with the check value of the source metadata indicates that the temporary synchronization file to be synchronized by the electronic device is consistent with the source file in the trusted electronic device. It can be generally understood that when the verification value of the temporary synchronization file is consistent with the verification value of the source metadata, the file to be synchronized, which is sent to the electronic device by the trusted electronic device, is not problematic, the electronic device performs synchronization based on the temporary synchronization file, and the finally synchronized file is accurate.
After determining that the temporary synchronization file passes the verification, the temporary synchronization file may be moved or copied to a designated storage location in the file system.
Optionally, when the check value of the temporary synchronization file is detected to be inconsistent with the check value of the source metadata, the temporary synchronization file indicating that the electronic device is to be synchronized is inconsistent with the source file in the trusted electronic device, and if file synchronization is continued, accuracy of a file synchronization result may be affected, so that file synchronization is not performed.
In the implementation mode, the consistency check is equivalent to that of the temporary synchronous file and the source file, and the file is synchronized when the temporary synchronous file and the source file are consistent, so that the finally synchronized file is accurate, and the accuracy of file synchronization is improved. The temporary synchronous file is checked, the synchronous file is not tampered, the error is not easy to occur in the synchronous process, the system of the electronic equipment in the trust ring is effectively prevented from being attacked by malicious software or viruses, and the safety of the file synchronous process is improved.
Optionally, in a possible implementation manner, the step S304 may further include steps S3041 to S3043, which is specifically as follows.
Referring to fig. 10, fig. 10 is a flowchart illustrating a file synchronization method according to another embodiment of the application. The method comprises the following steps:
s3041, deleting the local file corresponding to the temporary synchronous file in the file system.
S3042, modifying the file name of the temporary synchronous file.
S3043, storing the temporary synchronous file with the modified file name into a file system.
For example, if the temporary synchronization file is generated based on a difference between the local file and the file to be synchronized, that is, the temporary synchronization file is generated based on a file that has changed since the last synchronization, the temporary synchronization file is stored to a designated storage location in the file system by incremental synchronization, that is, the file that has sent the change is stored to the designated storage location on the basis of the local file. For example, on the basis of the local metadata shown in fig. 8, the newly added change data block 1, change data block 2 and change data block 3 are added to the corresponding storage positions of the local metadata, and meanwhile, the data block 4 in the local metadata is deleted, so that a new file after synchronization is obtained.
The multi-terminal synchronization of the file is completed in an incremental synchronization mode, so that the data volume of file transmission can be effectively reduced, and the bandwidth is saved. And the data volume of transmission is reduced, so that the file synchronization process is quickened, and the overall data synchronization efficiency is improved. Meanwhile, the electronic equipment only needs to process the changed files, so that the load in the file synchronization process is effectively reduced, and the power consumption of the electronic equipment is reduced.
If the temporary synchronization file comprises the changed file and the local file, namely the temporary synchronization file is already the file after synchronization, deleting the local file corresponding to the temporary synchronization file in the file system. The file name of the temporary synchronous file is modified to be different from the local file name, so that the user can conveniently distinguish the files after synchronization through the file names.
Alternatively, the file name of the temporary synchronization file may be modified to be the same as the file name of the local file, that is, the file name of the temporary synchronization file after modification is the same as the file name of the local file. Therefore, the consistency of the files before and after synchronization can be better ensured, and the user and the file system can conveniently identify and process the files after synchronization.
And copying or moving the temporary synchronous file with the modified file name from the temporary storage position to a designated storage position in the file system to realize file synchronization.
In the implementation mode, the local file is deleted first, and then the file name of the temporary synchronous file is modified, so that file name conflict can be avoided, errors caused by inconsistent file names or file versions are reduced, and the integrity and consistency of file synchronization are guaranteed.
Optionally, in one possible implementation manner, the file synchronization method provided in the embodiment of the present application may further include steps S401 to S405 before acquiring the file to be synchronized sent by the at least one trusted electronic device, which is specifically as follows.
Referring to fig. 11, fig. 11 is a flowchart illustrating a file synchronization method according to an embodiment of the application. The method comprises the following steps:
s401, acquiring local metadata.
The file synchronization service module in the electronic device may include a REPO management module, a file synchronization management module. Wherein the REPO management module may include a REPO catalog, and the REPO management module may be used to manage the REPO catalog.
For a local file, there is a piece of local metadata corresponding to the local file in a file system, and the file synchronization management module obtains the local metadata from the file system of the electronic device.
The file synchronization management module detects whether the local metadata matches the local file. For example, it is detected whether the information of the file name, the file size, the file creation time, the file last modification time, the file last access time, the file type, the file authority, the file owner, the file attribute flag, the file system information, the file version, the file extension attribute, the relative path, etc. in the local metadata is consistent with the information of the file name, the file size, the file creation time, the file last modification time, the file last access time, the file type, the file authority, the file owner, the file attribute flag, the file system information, the file version, the file extension attribute, the relative path, etc. of the local file.
If the file synchronization results are inconsistent, the file synchronization management module notifies the REPO management module that the file synchronization has failed, which means that the local file has changed in the electronic device or that the local file has a problem, and if the file synchronization is continued, the accuracy of the file synchronization results is affected.
If so, it indicates that the local file has not been changed in the electronic device, or that the local file has no problem, and then step S402 is continued.
In the implementation mode, the local metadata and the local file are checked first, and when the local metadata is matched with the local file, the follow-up file synchronization process is executed, so that the accuracy of the follow-up file synchronization result can be ensured.
And S402, comparing whether the local metadata are consistent with the source metadata or not when the local metadata are detected to be matched with the local file.
The file synchronization management module compares whether the local metadata are consistent with the source metadata, and the essence is whether the data blocks of the local metadata are consistent with the data blocks of the source metadata. Reference may be made specifically to the description of the corresponding embodiment in fig. 8, and no further description is given here.
Step S403 is performed when the local metadata is consistent with the source metadata, and step S404 is performed when the local metadata is inconsistent with the source metadata.
And S403, when the local metadata are consistent with the source metadata, updating the local file.
Illustratively, when the local metadata is consistent with the source metadata, it indicates that the file to be synchronized is unchanged from the local file, i.e., unchanged since the last time the trusted electronic device was file-synchronized with the electronic device. At this time, the local file may not be subjected to any operation, and the attribute of the local file may be updated. For example, the file synchronization management module sends the synchronization time, the file last access time, etc. to the file system, which updates the synchronization time, the file last access time, etc. of the local file.
Illustratively, when the local metadata is inconsistent with the source metadata, it indicates that the file to be synchronized is unchanged from the local file, that is, the file has changed since the trusted electronic device was last file-synchronized with the electronic device, and the local file needs to be file-synchronized, at this time, step S404 may be executed.
In the implementation mode, the local metadata and the local file, and the local metadata and the source metadata are checked, and when the verification is passed, the subsequent file synchronization flow is executed, so that the accuracy of the subsequent file synchronization result can be ensured.
And S404, when the local metadata are inconsistent with the source metadata, determining difference data between the local metadata and the source metadata.
For example, if the local metadata is inconsistent with the source metadata, the file synchronization management module may determine a difference data block between the data block of the local metadata and the data block of the source metadata, that is, determine difference data between the local metadata and the source metadata when comparing the data block of the local metadata and the data block of the source metadata. Reference may be made specifically to the relevant description in the corresponding embodiment of fig. 8, and this will not be repeated here.
And S405, sending the difference data to at least one trusted electronic device.
The difference data is used for triggering at least one trusted electronic device to send a file to be synchronized to the electronic device.
The file synchronization management module sends the difference data to the file synchronization management module of the trusted electronic device, and the file synchronization management module of the trusted electronic device sends the file to be synchronized to the file synchronization management module of the electronic device.
In the implementation mode, when the local file is determined to be different from the source file, the difference data is sent to the trusted electronic equipment, the trusted electronic equipment is triggered to send the file to be synchronized to the electronic equipment, and the guarantee is provided for achieving file synchronization.
Optionally, in one possible implementation, when comparing the data block of the local metadata with the data block of the source metadata, the file synchronization management module may send the first difference data block to the file synchronization management module of the trusted electronic device when determining the first difference data block. The first difference data block refers to a first different data block of source metadata compared with local metadata, and is also used for triggering the trusted electronic device to send a file to be synchronized to the electronic device.
It should be understood that when the file synchronization management module of the electronic device sends the first difference data block to the file synchronization management module of the trusted electronic device, the file synchronization management module carries the location information of the first difference data block.
In the implementation mode, when the first different data block of the source metadata and the local metadata is determined, the first different data block is sent to the trusted electronic equipment, and all data are not required to be compared, so that the computing resources can be obviously reduced, the file synchronization efficiency is improved, and the file synchronization time is saved. And only the first difference data block is sent, so that the use of network bandwidth can be reduced, the load of electronic equipment is reduced, and the overall performance of the system is improved.
Optionally, in one possible implementation manner, the file synchronization method provided by the application can further comprise the step of sending the source metadata and the difference data to at least one trusted electronic device.
The source end metadata is used for verifying whether the source end metadata is matched with a local file in the at least one trusted electronic device or not by the at least one trusted electronic device, and the difference data is used for triggering the at least one trusted electronic device to send a file to be synchronized to the electronic device when the source end metadata is matched with the local file in the at least one trusted electronic device.
The file synchronization management module of the electronic device illustratively sends the previously acquired source metadata, as well as the determined difference data or the first difference data block, to the file synchronization management module of the trusted electronic device.
For a local file of a trusted electronic device, there is also metadata corresponding to the local file in a file system of the trusted electronic device, and a file synchronization management module of the trusted electronic device obtains the metadata from the file system of the trusted electronic device. The file synchronization management module of the trusted electronic device detects whether the metadata matches a local file of the trusted electronic device. The specific detection method may refer to the similar description in step S401, and will not be repeated here.
When the metadata is not matched with the local file of the trusted electronic device, the local file is changed in the trusted electronic device, or the local file is problematic, and if the file synchronization is continued, the accuracy of the file synchronization result is affected, so that the file synchronization management module of the trusted electronic device notifies the file synchronization management module of the electronic device that the file synchronization fails.
When the metadata is matched with the local file of the trusted electronic device, the local file is unchanged in the trusted electronic device or the local file is free of problems, a file synchronization management module of the trusted electronic device determines a starting point (such as the beginning of a source file, the position after last synchronization and the like) in a file system, reads the source file block by block from the starting point, and generates a file to be synchronized. The file synchronization management module of the trusted electronic device sends the file to be synchronized to the file synchronization management module of the electronic device, and the file synchronization management module of the electronic device generates a temporary synchronization file based on the file to be synchronized, and then performs synchronization based on the temporary synchronization file.
In the implementation mode, the source file and the metadata of the trusted electronic equipment are checked first, and the subsequent file synchronization flow is executed under the condition that the source file has no problem, so that the accuracy of the subsequent file synchronization result can be ensured.
Referring to fig. 12, fig. 12 is a flowchart illustrating a file synchronization method according to another embodiment of the application. The method comprises the following steps:
s501, a file synchronization management module of the electronic equipment acquires local metadata.
S502, a file synchronization management module of the electronic equipment checks whether the local metadata are matched with the local file.
S503, when the file synchronization management module of the electronic device detects that the local metadata is not matched with the local file, notifying the REPO management module of file synchronization failure.
S504, when the file synchronization management module of the electronic equipment detects that the local metadata is matched with the local file, comparing whether the local metadata is consistent with the source metadata or not.
S505, when the file synchronization management module of the electronic equipment detects that the local metadata is consistent with the source metadata, the local file is updated.
S506, when the file synchronization management module of the electronic equipment detects that the local metadata are inconsistent with the source metadata, difference data between the local metadata and the source metadata are determined.
S507, the file synchronization management module of the electronic device sends the source metadata and the difference data to the file synchronization management module of the trusted electronic device.
S508, the file synchronization management module of the trusted electronic device acquires metadata from the file system of the trusted electronic device.
S509, the file synchronization management module of the trusted electronic device verifies whether the metadata of the source end and the metadata of the local file are consistent.
S510, the file synchronization management module of the trusted electronic device detects that the metadata of the source end is inconsistent with the metadata of the local file, and the file synchronization management module of the trusted electronic device informs the file synchronization management module of the electronic device of file synchronization failure.
S511, the file synchronization management module of the trusted electronic device detects that the metadata of the source end is consistent with the metadata of the local file, and generates a file to be synchronized based on the file system of the trusted electronic device.
S512, the file synchronization management module of the trusted electronic device sends the file to be synchronized to the file synchronization management module of the electronic device.
S513, the file synchronization management module of the electronic equipment generates a temporary synchronization file based on the file to be synchronized.
The specific implementation of step S501 to step S513 may be referred to the related description in the foregoing embodiments, and will not be repeated here.
Referring to fig. 13, fig. 13 is a flowchart illustrating another file synchronization method according to an embodiment of the application. The method comprises the following steps:
s601, a file synchronization management module of the electronic equipment generates a check value corresponding to the temporary synchronization file.
S602, a file synchronization management module of the electronic equipment verifies whether the verification value of the temporary synchronization file is consistent with the verification value of the source metadata.
And S603, deleting the local file corresponding to the temporary synchronous file in the file system when the check value of the temporary synchronous file is detected to be consistent with the check value of the source-end metadata.
S604, modifying the file name of the temporary synchronous file, and storing the temporary synchronous file with the modified file name into a file system.
S605, the file synchronization management module of the electronic device informs the REPO management module that the file synchronization is successful.
The specific implementation of step S601 to step S605 may be referred to the related description in the previous embodiments, and will not be repeated here.
The file synchronization method provided by the embodiment of the application is suitable for any scene requiring file synchronization in near field communication.
In the process of file synchronization between electronic devices in a trust ring, files in the electronic devices need to be monitored and scanned, or file paths/file catalogues corresponding to the files need to be monitored and scanned. When a plurality of file paths/file directories need to be monitored and scanned, even if the inclusion relationship exists among the plurality of file paths/file directories, in the related art, each file path/file directory needs to be monitored and scanned, and each monitoring needs to create a corresponding monitoring task, or each monitoring needs to start a corresponding monitoring thread, so that the number of started monitoring threads is increased, the number of times of scanning the file paths/file directories is excessive, and finally, the file synchronization efficiency is low and the power consumption of the electronic equipment is high.
In view of the above, the embodiment of the application also provides a method for processing data, which is applied to an electronic device, wherein a trust ring where the electronic device is located also comprises at least one trusted electronic device, and files in the electronic device can be synchronized into the at least one trusted electronic device.
The associated file path is a file path with a containing relation, the file path with the containing relation at least comprises a sub file path and a parent file path, a scanning result corresponding to the sub file path is notified to a scanning task corresponding to the parent file path, namely, a scanning result corresponding to the sub file path in the file path with the containing relation is notified to the parent file path in the file path with the containing relation.
Optionally, each scanning task corresponds to a file path, each file path corresponds to a file directory, and a file pointed by the file path and file content of the file can be found by scanning the file path.
Alternatively, the scanning task may include listening and scanning for file paths.
In the implementation manner, after the file paths with the inclusion relationship are determined, the scanning tasks corresponding to the file paths with the inclusion relationship are combined, and as the sub-file paths in the file paths with the inclusion relationship are notified of the scanning tasks corresponding to the parent file paths, even if the scanning tasks are combined, the scanning tasks corresponding to the file paths with the inclusion relationship can be ensured to be completed smoothly. And because the scanning tasks are combined, in the process of executing the combined scanning tasks, the same file path can be prevented from being scanned for multiple times, so that the scanning times are effectively reduced, namely the workload of repeated scanning is reduced, the power consumption of the electronic equipment is reduced, the resource allocation in the system is optimized, the whole file synchronization process is accelerated, and the subsequent file synchronization efficiency is improved.
Optionally, merging the scanning tasks corresponding to the associated file paths comprises obtaining at least two scanning time intervals corresponding to the associated file paths, merging the at least two scanning tasks corresponding to the associated file paths into a target scanning task, and setting the target scanning time intervals of the target scanning task according to the at least two scanning time intervals. The target scanning time interval is larger than or equal to the smallest scanning time interval in at least two scanning time intervals and smaller than the largest scanning time interval in at least two scanning time intervals. In the implementation mode, as the scanning tasks are combined, the same file path can be effectively prevented from being scanned for multiple times in the process of executing the combined scanning tasks, so that the scanning times are effectively reduced, namely the workload of repeated scanning is reduced, the power consumption of electronic equipment is reduced, the resource allocation in a system is optimized, the whole file synchronization process is accelerated, and the subsequent file synchronization efficiency is improved.
Optionally, the method for processing the data can further comprise the step of scanning a file path corresponding to the target scanning task according to the target scanning time interval to obtain a scanned file. The scan file is used to synchronize into at least one trusted electronic device within the trust ring. In the implementation mode, the file paths corresponding to the target scanning task are purposefully scanned without considering other file paths, so that the scanning efficiency is improved, the whole file synchronization process is further accelerated, and the subsequent file synchronization efficiency is improved.
Optionally, the method for processing the data further comprises the steps of obtaining a list to be scanned, scanning each file path in the list to be scanned according to a target scanning time interval, obtaining a scanning result of any file path when any file path in the associated file paths is scanned, and feeding back the scanning result to a scanning task corresponding to each file path in the associated file paths. The list to be scanned includes associated file paths, file paths of unassociated scanning tasks, and unassociated file paths of associated scanning tasks. Alternatively, the list to be scanned includes all file paths.
In the implementation mode, when the associated file path is scanned, each scanning task corresponding to the associated file path can be ensured to receive the notification of the scanning result, so that the files scanned based on each scanning task can be conveniently and subsequently synchronized to the trusted electronic equipment, the scanning times are reduced, the power consumption of the electronic equipment is reduced, and meanwhile, the accuracy of file synchronization is ensured.
Optionally, the method for processing data can further comprise setting a scanning start time of the target scanning task according to the target scanning time interval, and starting scanning when the current time reaches the scanning start time. In the implementation mode, the mode of setting the scanning starting time and then starting to scan the file path is adopted, so that the execution time of each scanning operation can be accurately recorded, and scanning errors are avoided. And determines the start and end times of each scanning operation, which helps to reasonably allocate system resources.
Optionally, feeding back the scanning result to the scanning task corresponding to each file path in the associated file paths, including adding the scanning result to a preset notification list. The notification list is used for feeding back the scanning result to the scanning task corresponding to each file path in the associated file paths.
Alternatively, the scan result may be obtained by calling a callback function.
In the implementation mode, the file scanned based on each scanning task is conveniently synchronized to the trusted electronic equipment, so that the scanning times are reduced, the power consumption of the electronic equipment is reduced, and meanwhile, the accuracy of file synchronization is guaranteed.
Optionally, the method for processing data can further comprise deleting all scanning results in the notification list after scanning each file path in the list to be scanned. In the implementation mode, all scanning results in the notification list are deleted once, so that the deleting step is simplified, and the deleting efficiency is improved.
Optionally, the method for processing data may further include deleting a scan result corresponding to any file path in the notification list after any file path in the associated file paths is scanned. In the implementation mode, a corresponding scanning result is deleted every time a file path is scanned, so that the storage space can be saved, the situation of error feedback is avoided, and the accuracy of file synchronization is improved.
Optionally, the method for processing data can further comprise acquiring a cancel scan notification and clearing a scan start time of the target scan task. The scan cancellation notification is used for canceling any scan task corresponding to the associated file path. In the implementation mode, when the cancellation of the scanning notification is acquired, the related information of the scanning task is cleared, so that more resources of the system can be released, the processing load of the system is reduced, and the processing speed of the system is improved. Meanwhile, different requirements of users in the file synchronization scene are responded in time, and user experience is improved.
Optionally, clearing the scan start time of the target scan job includes determining that no containment relationship exists between other plurality of file paths and clearing the scan start time of the target scan job. The other file paths are multiple file paths except the file path corresponding to any scanning task. When the implementation mode determines that the inclusion relation does not exist among other multiple file paths, the related information of the scanning task is cleared, the influence of the related information of the clearing scanning task on other scanning tasks is avoided, and the other scanning tasks can be successfully completed.
Optionally, after receiving the scan cancellation notification, the method for processing data may further include determining that an inclusion relationship exists between other multiple file paths, and merging scan tasks corresponding to the other multiple file paths having the inclusion relationship.
Optionally, determining that a containing relationship exists among other multiple file paths, acquiring scanning time intervals corresponding to the file paths with the containing relationship, merging scanning tasks corresponding to the file paths with the containing relationship into a new target scanning task, and setting the new scanning time intervals corresponding to the new target scanning task according to the scanning time intervals corresponding to the file paths with the containing relationship.
The new scanning time interval is larger than or equal to the smallest scanning time interval in the scanning time intervals corresponding to the file paths with the inclusion relationship, and smaller than the largest scanning time interval in the scanning time intervals corresponding to the file paths with the inclusion relationship.
In the implementation mode, after the cancellation of the scanning notification is obtained, the scanning tasks corresponding to the residual file paths with the inclusion relationship are combined, so that the repeated scanning of the same file path can be avoided when the combined scanning tasks are executed, the scanning times are effectively reduced, namely the repeated scanning workload is reduced, the power consumption of the electronic equipment is reduced, the resource allocation in the system is optimized, the whole file synchronization process is accelerated, and the subsequent file synchronization efficiency is improved.
It should be noted that the method for processing data provided by the application can be applied to any scene in which files need to be monitored and scanned. When file synchronization is performed between electronic devices in a trust ring, the method for processing data can be applied to the electronic devices and also can be applied to the trusted electronic devices.
In the related art, when file synchronization is performed between electronic devices in a trust ring, if at least two different directories in the electronic devices need to synchronize the same file from the trusted electronic device, or the same file in a source device (i.e., the trusted electronic device) needs to be synchronized under different directories in the electronic device. Typically, the trusted electronic device will send the same file to the electronic device at least twice, i.e. the trusted electronic device will send the same file to different directories in the electronic device, respectively. However, in the file synchronization process, the file needs to be checked every time the file is transmitted across devices, and the trusted electronic device transmits the same file to the electronic device for multiple times, which means that the same file needs to be checked for multiple times, so that the file transmission process is complex and tedious. Repeated transmission of the same file increases the use of network bandwidth and processing time, not only affects other file synchronization, but also reduces the efficiency of file synchronization. And repeated transmission for many times can also increase the power consumption of the electronic equipment and the trusted electronic equipment, increase the risk of data leakage and reduce the security of file synchronization.
In view of the above, the embodiment of the application also provides a file synchronization method, which is applied to electronic equipment, wherein the trust ring where the electronic equipment is located also comprises at least one trusted electronic equipment; any catalogue requests to acquire the same file from at least one trusted electronic device, any catalogue is any one catalogue of at least two catalogues, the acquired same file is sent to other catalogues by any catalogue, and the other catalogues are catalogues of at least two catalogues except any catalogue.
In this implementation, any directory in the electronic device first obtains the same file to be synchronized from the trusted electronic device, and then sends the same file to other directories in the electronic device. In the whole file synchronization process, the same file is transmitted only once across devices for the electronic device and the trusted electronic device, and the whole file transmission process is simple and convenient. Because the file transmission times are less, the use and processing time of network bandwidth are reduced, and the efficiency of file synchronization is improved while the power consumption of the electronic equipment and the trusted electronic equipment is reduced. The file transmission times are reduced, the risk of data leakage can be reduced, and the safety of file synchronization is improved.
And any directory in the electronic equipment transmits the same file to other directories in the electronic equipment, and the file is transmitted in the same electronic equipment, so that the transmission speed is high, the risk is low, and the efficiency and the safety of file synchronization are improved. No extra network bandwidth is consumed in the transmission process, the transmission cost is reduced, the influence of network fluctuation or external interference is not easy to occur, and the transmission reliability is improved. And the file operation is carried out in the same electronic equipment, so that the operating system and the file system of the electronic equipment can better maintain the attribute and the authority of the file and ensure the integrity of the file.
Optionally, determining that at least two directories in the electronic device synchronize the same file from at least one trusted electronic device includes obtaining a file list to be synchronized, comparing files to be synchronized corresponding to the at least two directories respectively, and determining that the at least two directories synchronize the same file from the at least one trusted electronic device when the files to be synchronized corresponding to the at least two directories respectively are consistent. The file list to be synchronized comprises files to be synchronized corresponding to at least two catalogues respectively. In the implementation manner, the files to be synchronized corresponding to the at least two catalogues are checked to ensure that the at least two catalogues are truly synchronized with the same file from the trusted electronic equipment, so that the files finally synchronized into each catalogue can be accurate, and the accuracy of file synchronization is improved.
Optionally, comparing the files to be synchronized corresponding to the at least two directories respectively includes obtaining metadata of the files to be synchronized corresponding to the at least two directories, and determining that the at least two directories synchronize the same file from at least one trusted electronic device when the metadata of the files to be synchronized corresponding to the at least two directories are consistent. In the implementation manner, the metadata of the files to be synchronized corresponding to the at least two directories are checked to ensure that the at least two directories are truly synchronized with the same file from the trusted electronic equipment, so that the files finally synchronized into each directory can be accurate, and the accuracy of file synchronization is improved.
Optionally, any directory request obtains the same file from at least one trusted electronic device, including any directory initiating a file synchronization request to at least one trusted electronic device, the file synchronization request being used to trigger the at least one trusted electronic device to send the same file to the electronic device, and marking other directories to synchronize the same file with any directory. In the implementation mode, after any directory initiates a file synchronization request to at least one trusted electronic device, other directories are marked, so that after the same file is acquired by any subsequent directory, the same file is quickly and accurately sent to the marked other directories, the file which is finally synchronized to each directory can be accurate, and the accuracy of file synchronization is improved.
Optionally, any directory sends the acquired same file to other directories, including acquiring file paths of the marked other directories, and copying the same file to the file paths of the marked other directories. In the implementation mode, after any directory in the electronic equipment acquires the same file to be synchronized, the same file is copied into the file paths of other directories according to the file paths of other marked directories, and the file is transmitted in the same electronic equipment, so that the transmission speed is high, the risk is low, and the efficiency and the safety of file synchronization are improved. No extra network bandwidth is consumed in the transmission process, the transmission cost is reduced, the influence of network fluctuation or external interference is not easy to occur, and the transmission reliability is improved. And the file operation is carried out in the same electronic equipment, so that the operating system and the file system of the electronic equipment can better maintain the attribute and the authority of the file and ensure the integrity of the file.
Optionally, the trust ring where the electronic device is located further comprises at least two trusted electronic devices, the at least two trusted electronic devices respectively store the same synchronous file, and the file synchronization method further comprises the steps of obtaining influence factors of each trusted electronic device, determining a synchronous source device in the at least two trusted electronic devices according to the influence factors of each trusted electronic device, and synchronizing the synchronous file from the synchronous source device. The influencing factor is used to influence the determination of the synchronization source device, i.e. the influencing factor is a factor for influencing which trusted electronic device is chosen as synchronization source device. The synchronization source device is different and the file synchronization effect is different, that is, influencing factors may be used to influence the file synchronization effect between the electronic device and the trusted electronic device. The influencing factors include at least one of a power state, a device type, a network state, a device performance, a current power consumption of the device, and a user preference.
In the implementation manner, the influence factors of each trusted electronic device are considered, so that the most proper synchronous source device can be selected from a plurality of trusted electronic devices, the synchronous operation can be ensured to be more efficient, and the consistency and the accuracy of the synchronous files are favorably kept. Meanwhile, the overload condition can be avoided, the reasonable allocation and optimized use of equipment resources are ensured, unnecessary resource consumption is reduced, the file synchronization cost is reduced, and the reliability of file synchronization is enhanced.
Optionally, determining the synchronization source device in the at least two trusted electronic devices based on the influencing factors of each trusted electronic device includes calculating a synchronization suitability score for each trusted electronic device based on the influencing factors of each trusted electronic device, and determining the synchronization source device in the at least two trusted electronic devices based on the synchronization suitability score of each trusted electronic device. In the implementation manner, the synchronization suitability score is calculated for the trusted electronic equipment, and the process of synchronizing the files by the synchronization source equipment is determined according to the synchronization suitability score, so that the most suitable synchronization source equipment can be selected from a plurality of trusted electronic equipment, the higher efficiency of synchronization operation can be ensured, and the consistency and accuracy of the synchronized files are maintained. Meanwhile, the overload condition can be avoided, the reasonable allocation and optimized use of equipment resources are ensured, unnecessary resource consumption is reduced, the file synchronization cost is reduced, and the reliability of file synchronization is enhanced.
Optionally, the device types of the at least two trusted electronic devices are different, and the synchronous source device is determined in the at least two trusted electronic devices according to the influence factor of each trusted electronic device, wherein the method comprises the steps of determining the priority of each trusted electronic device according to the influence factor of each trusted electronic device; a synchronization source device is determined among the at least two trusted electronic devices based on the priority of each trusted electronic device. In the implementation mode, the synchronous source equipment is determined by determining the priority of the equipment, and resources can be reasonably allocated according to the importance and the functions of different equipment, so that the proper synchronous source equipment can be chosen, and the efficiency and the accuracy of the subsequent file synchronization are improved.
The file synchronization method provided by the embodiment of the application is described above with reference to the flowchart, and the hardware structure of the electronic device related to the embodiment of the application is briefly introduced with reference to the accompanying drawings.
In some embodiments of the present application, the electronic device may be a mobile phone, a tablet computer, a wearable device, a television, a vehicle-mounted device, an augmented reality (augmented reality, AR)/Virtual Reality (VR) device, a notebook computer, an ultra-mobile personal computer, a UMPC, a netbook, a Personal Digital Assistant (PDA), or the like, or may be other devices or apparatuses capable of performing scene recognition, and the embodiments of the present application are not limited in any way with respect to the specific type of electronic device.
Referring to fig. 14, fig. 14 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the application.
As shown in fig. 14, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, keys 190, a motor 191, an indicator 192, a camera 193, a display 194, a subscriber identity module (subscriber identification module, SIM) card interface 195, and the like. The sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It should be understood that the illustrated structure of the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the application, electronic device 100 may include more or fewer components than those shown in FIG. 14, or electronic device 100 may include a combination of some of the components shown in FIG. 14, or electronic device 100 may include sub-components of some of the components shown in FIG. 14. The components shown in fig. 14 may be implemented in hardware, software, or a combination of software and hardware.
The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (IMAGE SIGNAL processor, ISP), a controller, a video codec, a digital signal processor (DIGITAL SIGNAL processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc.
It should be understood that the connection relationship between the modules illustrated in this embodiment is only illustrative, and does not limit the structure of the electronic device 100. In other embodiments, the electronic device 100 may also employ different interfaces in the above embodiments, or a combination of interfaces.
The electronic device 100 may implement display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, and is connected to the display 194 and the application processor. GPUs can also be used to perform mathematical and pose calculations, for graphics rendering, and the like. Processor 110 may include one or more GPUs, the execution of which may generate or change display information.
The display 194 may be used to display images or video and may also display a series of graphical user interfaces (GRAPHICAL USER INTERFACE, GUIs), all of which are the home screen of the electronic device 100. Generally, the size of the display 194 of the electronic device 100 is fixed and only limited controls can be displayed in the display 194 of the electronic device 100. A control is a GUI element that is a software component that is included in an application program, controls all data processed by the application program and interactive operations on the data, and a user can interact with the control by direct operations (direct manipulation) to read or edit information about the application program. In general, controls may include visual interface elements such as icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets (widgets), and the like.
The display screen 194 in embodiments of the present application may be a touch screen. The display 194 may have the touch sensor 180K integrated therein. The touch sensor 180K may also be referred to as a "touch panel". That is, the display screen 194 may include a display panel and a touch panel, and a touch screen, also referred to as a "touch screen", is composed of the touch sensor 180K and the display screen 194. The touch sensor 180K is for detecting a touch operation acting thereon or thereabout. After a touch operation detected by the touch sensor 180K, a driving (e.g., TP driving) of the kernel layer may be transferred to an upper layer to determine a touch event type. Visual output related to the touch operation may be provided through the display 194. In other embodiments, the touch sensor 180K may also be disposed on the surface of the electronic device 100 at a different location than the display 194.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. For example, files such as music, video, etc. are stored in an external memory card.
The internal memory 121 may be used to store computer-executable program code that includes instructions. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 121. The internal memory 121 may include a storage program area and a storage data area. The storage program area may store an operating system, an APP (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like. The storage data area may store data created during use of the electronic device 100 (e.g., audio data, phonebook, etc.), and so on.
In addition, the internal memory 121 may include a high-speed random access memory, and the internal memory 121 may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (Universal Flash Storage, UFS), and the like.
The keys 190 include a power-on key, a volume key, etc. The keys 190 may be mechanical keys. Or may be a touch key. The electronic device 100 may receive key inputs, generating key signal inputs related to user settings and function controls of the electronic device 100.
The motor 191 may generate a vibration cue. The motor 191 may be used for incoming call vibration alerting as well as for touch vibration feedback.
The file synchronization method and the file synchronization method provided in the embodiments of the present application may be implemented in the electronic device 100 having the above-described hardware structure.
The file synchronization method provided by the application is described below in connection with a software structure. Referring to fig. 15, fig. 15 is a schematic software structure of an electronic device according to an embodiment of the application.
Illustratively, the layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate with each other through a software interface. In the embodiment of the present application, an Android system is described as an example, and the Android system is divided into an Application (App) layer, an Application Framework (Framework) layer, and a hardware abstraction layer.
The application layer may include a series of application packages, such as a trust ring application, among others. In the embodiment of the application, the file synchronization SDK is integrated in the trust ring application, so that the trust ring application is configured with the file synchronization capability.
Optionally, the application layer may also include a database. The database provides functions such as data storage, data modification, data deletion, data addition, data query and the like for the application program.
The application framework layer provides an application programming interface (Application Programming Interface, API) and programming framework for the application of the application layer. The application framework layer includes a number of predefined functions.
As an example of the present application, the application framework layer includes a file synchronization service module, which may include a REPO management module, a listening scan management module, and a timer. Wherein the REPO management module may include a REPO catalog, and the REPO management module may be used to manage the REPO catalog.
Alternatively, the application framework layer may also include a database.
Alternatively, the database may interact with a hardware abstraction layer, such as by operating system calls and managing data in a file system.
Alternatively, the hardware abstraction layer may comprise a file system.
The trust ring application, the file synchronization service module, the database and the file system implement the method for processing data and the file synchronization method in the above method embodiments through interaction, and specific reference may be made to the descriptions related to the foregoing embodiments, which are not repeated herein.
Examples of the file synchronization method provided by the embodiment of the application are described in detail above. It will be appreciated that the electronic device, in order to achieve the above-described functions, includes corresponding hardware and/or software modules that perform the respective functions. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application in conjunction with the embodiments, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application can divide the functional modules of the electronic device according to the method example, for example, the functional modules can be divided into the functional modules corresponding to the functions, and two or more functions can be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. It should be noted that, in the embodiment of the present application, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation.
It should be noted that, all relevant contents of each step related to the above method embodiment may be cited to the functional description of the corresponding functional module, which is not described herein.
The electronic device provided in this embodiment is configured to execute the file synchronization method, so that the same effect as that of the implementation method can be achieved.
In case an integrated unit is employed, the electronic device may further comprise a processing module, a storage module and a communication module. The processing module can be used for controlling and managing the actions of the electronic equipment. The memory module may be used to support the electronic device to execute stored program code, data, etc. And the communication module can be used for supporting the communication between the electronic device and other devices.
Wherein the processing module may be a processor or a controller. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. A processor may also be a combination that performs computing functions, e.g., including one or more microprocessors, digital Signal Processing (DSP) and a combination of microprocessors, and the like. The memory module may be a memory. The communication module can be a radio frequency circuit, a Bluetooth chip, a WiFi chip and other equipment which interact with other electronic equipment.
The embodiment of the application also provides a computer readable storage medium, in which a computer program is stored, which when executed by a processor, causes the processor to execute the file synchronization method of any of the above embodiments.
The embodiment of the application also provides a device which can be a chip, a component or a module, and the device can comprise a processor and a memory which are connected, wherein the memory is used for storing computer execution instructions, and when the device runs, the processor can execute the computer execution instructions stored in the memory so that the chip can execute the method for processing data and the file synchronization method in the method embodiments.
The embodiment of the application also provides a computer program product, which when run on a computer, causes the computer to execute the above related steps to implement the file synchronization method in the above embodiment.
The embodiment of the application also provides a chip. Referring to fig. 16, fig. 16 is a schematic structural diagram of a chip according to an embodiment of the application. The chip shown in fig. 16 may be a general-purpose processor or a special-purpose processor. The chip includes a processor 210. The processor 210 is configured to perform the method for processing data and the file synchronization method according to any of the above embodiments.
Optionally, the chip further comprises a transceiver 220, and the transceiver 220 is configured to receive control of the processor and is configured to support the communication device to perform the foregoing technical solution.
Optionally, the chip shown in FIG. 16 may also include a storage medium 230.
It is noted that the chip shown in fig. 16 may be implemented using one or more field programmable gate arrays (field programmable GATE ARRAY, FPGAs), programmable logic devices (programmable logic device, PLDs), controllers, state machines, gate logic, discrete hardware components, any other suitable circuit, or any combination of circuits capable of performing the various functions described throughout this application.
The electronic device, the computer readable storage medium, the computer program product or the chip provided in this embodiment are used to execute the corresponding method provided above, so that the beneficial effects thereof can be referred to the beneficial effects in the corresponding method provided above, and will not be described herein.
It will be appreciated by those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and the parts shown as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a readable storage medium. Based on such understanding, the technical solution of the embodiments of the present application may be essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including several instructions for causing a device (may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps of the methods of the embodiments of the present application. The storage medium includes a U disk, a removable hard disk, a Read Only Memory (ROM), a random access memory (random access memory, RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (12)

Translated fromChinese
1.一种文件同步方法,其特征在于,应用于电子设备,所述电子设备所在的信任环还包括至少一个受信任电子设备,所述方法包括:1. A file synchronization method, characterized in that it is applied to an electronic device, wherein the trust ring in which the electronic device is located also includes at least one trusted electronic device, and the method comprises:获取所述至少一个受信任电子设备发送的待同步文件;Acquire a file to be synchronized sent by the at least one trusted electronic device;根据所述待同步文件生成临时同步文件;Generate a temporary synchronization file according to the file to be synchronized;校验所述临时同步文件;Verifying the temporary synchronization file;当所述临时同步文件校验通过时,将所述临时同步文件同步至文件系统中。When the temporary synchronization file passes the verification, the temporary synchronization file is synchronized to the file system.2.根据权利要求1所述的方法,其特征在于,所述校验所述临时同步文件,包括:2. The method according to claim 1, characterized in that the checking of the temporary synchronization file comprises:获取所述至少一个受信任电子设备发送的源端元数据;Acquiring source metadata sent by the at least one trusted electronic device;生成所述临时同步文件对应的校验值和所述源端元数据对应的校验值;Generate a check value corresponding to the temporary synchronization file and a check value corresponding to the source end metadata;检测到所述临时同步文件的校验值与所述源端元数据的校验值一致时,确定所述临时同步文件校验通过。When it is detected that the check value of the temporary synchronization file is consistent with the check value of the source-end metadata, it is determined that the temporary synchronization file has passed the check.3.根据权利要求1或2所述的方法,其特征在于,所述将所述临时同步文件同步至文件系统中,包括:3. The method according to claim 1 or 2, characterized in that synchronizing the temporary synchronization file to the file system comprises:在所述文件系统中删除与所述临时同步文件对应的本地文件;Deleting the local file corresponding to the temporary synchronization file in the file system;修改所述临时同步文件的文件名;Modify the file name of the temporary synchronization file;将修改文件名后的临时同步文件存储至所述文件系统中。The temporary synchronization file with the modified file name is stored in the file system.4.根据权利要求3所述的方法,其特征在于,所述根据所述待同步文件生成临时同步文件,包括:4. The method according to claim 3, characterized in that generating a temporary synchronization file according to the file to be synchronized comprises:对所述本地文件和所述待同步文件进行增量同步,生成所述临时同步文件。Incrementally synchronize the local file and the file to be synchronized to generate the temporary synchronization file.5.根据权利要求3或4所述的方法,其特征在于,在所述获取所述至少一个受信任电子设备发送的待同步文件之前,所述方法还包括:5. The method according to claim 3 or 4, characterized in that before obtaining the to-be-synchronized file sent by the at least one trusted electronic device, the method further comprises:获取本地元数据;Get local metadata;检测到所述本地元数据与所述本地文件匹配时,对比所述本地元数据与所述源端元数据是否一致;When it is detected that the local metadata matches the local file, comparing the local metadata with the source-end metadata to see whether they are consistent;所述本地元数据与所述源端元数据一致时,更新所述本地文件。When the local metadata is consistent with the source metadata, the local file is updated.6.根据权利要求5所述的方法,其特征在于,在所述检测到所述本地元数据与本地文件匹配时,对比所述本地元数据与所述源端元数据是否一致之后,所述方法还包括:6. The method according to claim 5, characterized in that, when the local metadata is detected to match the local file, after comparing whether the local metadata is consistent with the source metadata, the method further comprises:所述本地元数据与所述源端元数据不一致时,确定所述本地元数据与所述源端元数据之间的差异数据;When the local metadata is inconsistent with the source metadata, determining difference data between the local metadata and the source metadata;将所述差异数据发送至所述至少一个受信任电子设备中,所述差异数据用于触发所述至少一个受信任电子设备向所述电子设备发送所述待同步文件。The difference data is sent to the at least one trusted electronic device, where the difference data is used to trigger the at least one trusted electronic device to send the file to be synchronized to the electronic device.7.根据权利要求6所述的方法,其特征在于,在所述本地元数据与所述源端元数据不一致时,确定所述本地元数据与所述源端元数据之间的差异数据之后,所述方法还包括:7. The method according to claim 6, characterized in that when the local metadata is inconsistent with the source metadata, after determining the difference data between the local metadata and the source metadata, the method further comprises:将所述源端元数据和所述差异数据发送至所述至少一个受信任电子设备中,所述源端元数据用于所述至少一个受信任电子设备校验所述源端元数据与所述至少一个受信任电子设备中的本地文件是否匹配;所述差异数据用于触发所述至少一个受信任电子设备在所述源端元数据与所述至少一个受信任电子设备中的本地文件匹配时,向所述电子设备发送所述待同步文件。The source metadata and the difference data are sent to the at least one trusted electronic device, the source metadata is used by the at least one trusted electronic device to verify whether the source metadata matches the local file in the at least one trusted electronic device; the difference data is used to trigger the at least one trusted electronic device to send the file to be synchronized to the electronic device when the source metadata matches the local file in the at least one trusted electronic device.8.根据权利要求2至7任一项所述的方法,其特征在于,所述临时同步文件的校验值包括弱哈希值。8. The method according to any one of claims 2 to 7, characterized in that the check value of the temporary synchronization file includes a weak hash value.9.根据权利要求3至8任一项所述的方法,其特征在于,所述临时同步文件修改后的文件名与所述本地文件的文件名一致。9. The method according to any one of claims 3 to 8, characterized in that the modified file name of the temporary synchronization file is consistent with the file name of the local file.10.一种电子设备,其特征在于,包括:一个或多个处理器;一个或多个存储器;所述存储器存储有一个或多个程序,当所述一个或者多个程序被所述处理器执行时,使得所述电子设备执行权利要求1至9中任一项所述的方法。10. An electronic device, characterized in that it comprises: one or more processors; one or more memories; the memories store one or more programs, and when the one or more programs are executed by the processors, the electronic device executes the method according to any one of claims 1 to 9.11.一种芯片,其特征在于,包括:处理器,用于从存储器中调用并运行计算机程序,使得安装有所述芯片的电子设备执行如权利要求1至9中任一项所述的方法。11. A chip, characterized by comprising: a processor, configured to call and run a computer program from a memory, so that an electronic device equipped with the chip executes the method according to any one of claims 1 to 9.12.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储了计算机程序,当所述计算机程序被处理器执行时,使得所述处理器执行权利要求1至9中任一项所述的方法。12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the processor executes the method according to any one of claims 1 to 9.
CN202410386081.7A2024-03-292024-03-29 File synchronization method, electronic device and storage mediumPendingCN119248736A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202410386081.7ACN119248736A (en)2024-03-292024-03-29 File synchronization method, electronic device and storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202410386081.7ACN119248736A (en)2024-03-292024-03-29 File synchronization method, electronic device and storage medium

Publications (1)

Publication NumberPublication Date
CN119248736Atrue CN119248736A (en)2025-01-03

Family

ID=94033353

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202410386081.7APendingCN119248736A (en)2024-03-292024-03-29 File synchronization method, electronic device and storage medium

Country Status (1)

CountryLink
CN (1)CN119248736A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20170235792A1 (en)*2016-02-172017-08-17Www.Trustscience.Com Inc.Searching for entities based on trust score and geography
CN114329020A (en)*2020-03-262022-04-12华为技术有限公司Data sharing method, electronic equipment and system
CN116194923A (en)*2020-09-252023-05-30微软技术许可有限责任公司Image security using source identification
CN117763627A (en)*2023-12-292024-03-26中国电信股份有限公司File verification method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20170235792A1 (en)*2016-02-172017-08-17Www.Trustscience.Com Inc.Searching for entities based on trust score and geography
CN114329020A (en)*2020-03-262022-04-12华为技术有限公司Data sharing method, electronic equipment and system
CN116194923A (en)*2020-09-252023-05-30微软技术许可有限责任公司Image security using source identification
CN117763627A (en)*2023-12-292024-03-26中国电信股份有限公司File verification method and device, electronic equipment and storage medium

Similar Documents

PublicationPublication DateTitle
US9384098B1 (en)Portable data archiving device
JP2020501209A (en) Malware detection and restoration of content items
CN106453589B (en)Method and device for synchronizing backup data
AU2019461393A1 (en)Screen sharing processing method, apparatus and device, and storage medium
US20140304384A1 (en)Uploading large content items
US9930063B2 (en)Random identifier generation for offline database
US20140297586A1 (en)Device and method for cloud file management
US20180020047A1 (en)File information system management system and method
CN107632872B (en)Desktop layout processing method, user data processing method and device and computer storage medium
CN109753379B (en)Snapshot data backup and deletion method, device and system
CN106599115B (en) Data protection method, device and terminal
US8966238B2 (en)Personalization of shared electronic devices
CN104168536B (en)Data copy method and system between a kind of mobile terminal
WO2021233351A1 (en)Data transfer method and device, and terminal and computer-readable storage medium
CN113297615A (en)Mobile terminal and data encryption method thereof
CN110362330B (en)Application program updating method, device, terminal and storage medium
CN114048469B (en) Directory operation management method, electronic device and readable storage medium
CN119248736A (en) File synchronization method, electronic device and storage medium
CN108647285B (en) Renaming method, device and distributed file system in distributed file system
WO2017156931A1 (en)Locking method and system for mobile terminal
CN116527337A (en)Cluster data information access method, device, equipment and storage medium
KR20200111989A (en)Electronic device for searching a file information stored in external device and method of operating thereof
CN119248738A (en) Data processing method, electronic device and storage medium
CN114138293B (en) A terminal and external memory card portable system upgrade method
EP2687999A1 (en)Method and terminal for automatic data replication

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
CB02Change of applicant information
CB02Change of applicant information

Country or region after:China

Address after:Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040

Applicant after:Honor Terminal Co.,Ltd.

Address before:3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong

Applicant before:Honor Device Co.,Ltd.

Country or region before:China


[8]ページ先頭

©2009-2025 Movatter.jp