Method of processing data, electronic device, and storage medium
By merging the scanning tasks for associated file paths, the problem of low efficiency and high power consumption caused by excessive scanning during file synchronization is solved, achieving more efficient file synchronization.
Patent Information
- Application Number
- CN202410391850.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-29
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-03-29
AI Technical Summary
During file synchronization, excessive file scanning can lead to low efficiency and high device power consumption.
By merging scan tasks for associated file paths, duplicate scans of the same file path are reduced, system resource allocation is optimized, and the file synchronization process is accelerated.
It effectively reduces the number of file scans, lowers device power consumption, and improves file synchronization efficiency.
Smart Images

Figure CN119248738B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a data processing method, an electronic device and a storage medium. BACKGROUND
[0002] With the development of communication technology, distributed technology is increasingly applied to electronic devices. Distributed technology brings users a more relaxed and convenient experience in some scenarios such as office, data storage, data access, and the like.
[0003] For example, in a distributed file synchronization scenario, a mobile phone and other electronic devices (such as a tablet computer, a notebook computer, a home storage device, and the like) are connected through near field communication. For example, a local area network is formed by using wireless fidelity (Wi-Fi), bluetooth (BT), peer-to-peer (P2P), and the like, a trust ring is established, and files in the mobile phone are synchronized to other electronic devices.
[0004] However, it is found in use that the number of file scanning times is too high in the file synchronization process, resulting in low file synchronization efficiency and high device power consumption. SUMMARY
[0005] The present application provides a data processing method, an electronic device and a storage medium, which can reduce the number of file scanning times, improve file synchronization efficiency, and reduce device power consumption in the file synchronization process.
[0006] In a first aspect, the present application provides a data processing method applied to an electronic device, a trust ring in which the electronic device is located further includes at least one trusted electronic device, and files in the electronic device can be synchronized to the at least one trusted electronic device, the method comprising: obtaining a file synchronization request; determining a plurality of scanning tasks corresponding to the file synchronization request; determining an associated file path in a plurality of file paths, and merging scanning tasks corresponding to the associated file path.
[0007] The associated file path is a file path having a containing relationship; the file path having the containing relationship includes at least one child file path and one parent file path, and a scanning result corresponding to the child file path is notified to a scanning task corresponding to the parent file path, that is, a scanning result corresponding to a child file path in the file path having the containing relationship is notified to a parent file path in the file path having the containing relationship.
[0008] Optionally, each scanning task corresponds to a file path, each file path corresponds to a file directory, and the file path and file content of the file pointed to by the file path can be found by scanning the file path.
[0009] Optionally, the scanning task can include monitoring and scanning the file path.
[0010] Optionally, the file synchronization request can be triggered by the electronic device or by the trusted electronic device.
[0011] In this implementation, after determining the file paths having the containment relationship, the scanning tasks corresponding to the file paths having the containment relationship are merged. Since the file paths having the containment relationship include the sub-file paths, the scanning results corresponding to the sub-file paths are notified to the scanning tasks corresponding to the parent file paths. Thus, even if the scanning tasks are merged, the scanning tasks corresponding to the file paths having the containment relationship can be successfully completed. Moreover, since the scanning tasks are merged, in the process of executing the merged scanning tasks, multiple scanning of the same file path can be avoided, thereby effectively reducing the number of scanning, reducing the workload of repeated scanning, reducing the power consumption of the electronic device, optimizing the allocation of resources in the system, accelerating the entire file synchronization process, and improving the subsequent file synchronization efficiency.
[0012] In combination with the first aspect, in some implementations of the first aspect, merging the scanning tasks corresponding to the associated file paths includes: 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 a target scanning time interval of the target scanning task according to the at least two scanning time intervals.
[0013] Optionally, the scanning time intervals corresponding to different file paths are different; the target scanning time interval is greater than or equal to the smallest scanning time interval in the at least two scanning time intervals and smaller than the largest scanning time interval in the at least two scanning time intervals.
[0014] In this implementation, since the scanning tasks are merged, in the process of executing the merged scanning tasks, multiple scanning of the same file path can be effectively avoided, thereby effectively reducing the number of scanning, reducing the workload of repeated scanning, reducing the power consumption of the electronic device, optimizing the allocation of resources in the system, accelerating the entire file synchronization process, and improving the subsequent file synchronization efficiency.
[0015] In combination with the first aspect, in some implementations of the first aspect, the method of processing data can further include: scanning the file path corresponding to the target scanning task according to the target scanning time interval to obtain a scanned file.
[0016] Optionally, the scanned file is used for synchronization to at least one trusted electronic device in the trust circle.
[0017] In this implementation, the file path corresponding to the target scanning task is scanned purposefully without considering other file paths, the scanning efficiency is improved, the entire file synchronization process is accelerated, and the subsequent file synchronization efficiency is improved.
[0018] With reference to the first aspect, in some implementations of the first aspect, the method for processing data can further include: obtaining a scanning list, scanning each file path in the scanning list according to a target scanning time interval, obtaining a scanning result of any file path in the associated file path when any file path in the associated file path is scanned; and feeding back the scanning result to each scanning task corresponding to each file path in the associated file path.
[0019] Optionally, the scanning list includes the associated file path, the file path not associated with the scanning task, and the non-associated file path associated with the scanning task. Alternatively, the scanning list includes all file paths.
[0020] In this implementation, when the associated file path is scanned, each scanning task corresponding to the associated file path can be ensured to receive the scanning result notification, which facilitates subsequent synchronization of files scanned based on the scanning tasks to the trusted electronic device, and provides a guarantee for the accuracy of file synchronization while reducing the number of scans and reducing the power consumption of the electronic device.
[0021] With reference to the first aspect, in some implementations of the first aspect, the method for processing data can further include: setting a scanning start time of the target scanning task according to a target scanning time interval; and starting scanning when the current time reaches the scanning start time.
[0022] In this implementation, the scanning start time is set before the scanning of the file path is started, which can accurately record the execution time of each scanning operation and avoid scanning errors. Determining the start and end times of each scanning operation helps to reasonably allocate system resources.
[0023] With reference to the first aspect, in some implementations of the first aspect, feeding back the scanning result to each scanning task corresponding to each file path in the associated file path includes: adding the scanning result to a preset notification list.
[0024] The notification list is used to feed back the scanning result to each scanning task corresponding to each file path in the associated file path.
[0025] Optionally, the scanning result can be obtained by calling a callback function.
[0026] In this implementation, the files scanned based on the scanning tasks are beneficial to subsequent synchronization to the trusted electronic device, which reduces the number of scans and the power consumption of the electronic device while providing a guarantee for the accuracy of file synchronization.
[0027] With reference to the first aspect, in some implementations of the first aspect, the method for processing data can further include: after scanning each file path in the to-be-scanned list, deleting all scanning results in the notification list.
[0028] In this implementation, all scanning results in the notification list are deleted at one time, which simplifies the deletion step and improves the deletion efficiency.
[0029] With reference to the first aspect, in some implementations of the first aspect, the method for processing data can further include: after scanning any file path in the associated file path, deleting the scanning result corresponding to the any file path in the notification list.
[0030] In this implementation, one scanning result is deleted after scanning one file path, which can save storage space, avoid false feedback, and improve the accuracy of file synchronization.
[0031] With reference to the first aspect, in some implementations of the first aspect, the method for processing data can further include: obtaining a scanning cancellation notification, and clearing the scanning start time of the target scanning task.
[0032] The scanning cancellation notification is used to cancel any scanning task corresponding to the associated file path.
[0033] In this implementation, when the scanning cancellation notification is obtained, the related information of the scanning task is cleared, which can release more system resources, reduce the processing burden of the system, and improve the processing speed of the system. At the same time, different needs of users in the file synchronization scenario are responded in a timely manner, and the user experience is improved.
[0034] With reference to the first aspect, in some implementations of the first aspect, clearing the scanning start time of the target scanning task includes: determining that there is no containing relationship among other multiple file paths; and clearing the scanning start time of the target scanning task.
[0035] The other multiple file paths are multiple file paths other than the file path corresponding to any scanning task.
[0036] In this implementation, when it is determined that there is no containing relationship among the other multiple file paths, the related information of the scanning task is cleared, which avoids affecting other scanning tasks when the related information of the scanning task is cleared, and ensures that other scanning tasks can be completed smoothly.
[0037] With reference to the first aspect, in some implementations of the first aspect, after obtaining the cancel scanning notification, the method of processing data further includes: determining that there is a containing relationship between the other plurality of file paths; and merging the scanning tasks corresponding to the other plurality of file paths having the containing relationship.
[0038] Optionally, the determining that there is a containing relationship between the other plurality of file paths, the obtaining of the scanning time intervals corresponding to the file paths having the containing relationship, and the merging of the scanning tasks corresponding to the file paths having the containing relationship into the new target scanning task are performed according to the scanning time intervals corresponding to the file paths having the containing relationship.
[0039] The new scanning time interval is greater than or equal to the smallest scanning time interval among the scanning time intervals corresponding to the file paths having the containing relationship, and is less than the largest scanning time interval among the scanning time intervals corresponding to the file paths having the containing relationship.
[0040] In this implementation, after obtaining the cancel scanning notification, the scanning tasks corresponding to the remaining file paths having the containing relationship are merged, so that when the merged scanning task is executed, multiple scanning of the same file path can be avoided, thereby effectively reducing the number of scans, i.e., reducing the workload of repeated scanning, reducing the power consumption of the electronic device, optimizing the allocation of resources in the system, speeding up the entire file synchronization process, and improving the subsequent file synchronization efficiency.
[0041] In a second aspect, the present application provides an electronic device, which includes: one or more processors; one or more memories; a module installed with a plurality of application programs; and the memory stores one or more programs, when the one or more programs are executed by the processor, the electronic device executes the method in the first aspect and any possible implementation manner thereof.
[0042] In a third aspect, the present application provides a device for processing data, which includes units for executing any method in the first aspect. The device can be a server, an electronic device, or a chip in an electronic device. The device can include an input unit and a processing unit.
[0043] When the device is an electronic device, the processing unit can be a processor, and the input unit can be a communication interface. The electronic device can further include a memory for storing computer program codes, and when the processor executes the computer program codes stored in the memory, the electronic device executes any method in the first aspect.
[0044] When the device is a chip in an electronic device, the processing unit can be a processing unit inside the chip, and the input unit can be an output interface, a pin, or a circuit, etc. The chip can further include a memory, which can be a memory (e.g., a register, a cache, etc.) inside the chip, or a memory (e.g., a read-only memory, a random access memory, etc.) outside the chip. The memory is configured to store computer program code, and when the processor executes the computer program code stored in the memory, the chip is caused to perform the method in any one of the first aspect and any possible implementation manner thereof.
[0045] In a fourth aspect, the present application provides a chip, including a processor. The processor is configured to read and execute computer program stored in a memory, so as to perform the method in the first aspect and any possible implementation manner thereof.
[0046] Optionally, the chip further includes a memory, and the memory is connected to the processor through a circuit or a wire.
[0047] Optionally, the chip further includes a communication interface.
[0048] In a fifth aspect, the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is executed by a processor, the processor is caused to perform the method in the first aspect and any possible implementation manner thereof.
[0049] In a sixth aspect, the present application provides a computer program product, and the computer program product includes computer program code. When the computer program code is executed on an electronic device, the electronic device is caused to perform the method in the first aspect and any possible implementation manner thereof.
[0050] The technical effects obtained by the second aspect, the third aspect, the fourth aspect, the fifth aspect and the sixth aspect are similar to the technical effects obtained by the corresponding technical means in the first aspect, and thus will not be described herein. BRIEF DESCRIPTION OF DRAWINGS
[0051] Figure 1 A system architecture diagram suitable for the method for processing data shown in the embodiments of the present application;
[0052] Figure 2 Another system architecture diagram suitable for the method for processing data shown in the embodiments of the present application;
[0053] Figure 3 An application scenario diagram of file synchronization shown in the embodiments of the present application;
[0054] Figure 4 A diagram based on external storage backup data shown in the embodiments of the present application;
[0055] Figure 5 A backup data process diagram shown in an embodiment of the present application;
[0056] Figure 6 A file synchronization process diagram shown in an embodiment of the present application;
[0057] Figure 7 A file directory diagram shown in an embodiment of the present application;
[0058] Figure 8 A flow diagram of a method for processing data shown in an embodiment of the present application;
[0059] Figure 9 Another file directory diagram shown in an embodiment of the present application;
[0060] Figure 10 A flow diagram of another method for processing data shown in an embodiment of the present application;
[0061] Figure 11 A flow diagram of a method for scanning files shown in an embodiment of the present application;
[0062] Figure 12 A flow diagram of a method for setting a timing scan shown in an embodiment of the present application;
[0063] Figure 13 A flow diagram of a method for timing scanning a file path shown in an embodiment of the present application;
[0064] Figure 14 A flow diagram of a method for canceling a scanning task shown in an embodiment of the present application;
[0065] Figure 15 Another flow diagram of a method for canceling a scanning task shown in an embodiment of the present application;
[0066] Figure 16 A hardware structure diagram of an electronic device shown in an embodiment of the present application;
[0067] Figure 17 A software structure diagram of an electronic device shown in an embodiment of the present application;
[0068] Figure 18 A structure diagram of a chip shown in an embodiment of the present application. DETAILED DESCRIPTION
[0069] The technical solutions in the present application will be described below with reference to the accompanying drawings.
[0070] In the description of the embodiments of the present application, unless otherwise specified, " / " means the meaning of or, for example, A / B can mean A or B; "and / or" herein is only a description of the relationship between the associated objects, which means that there can be three relationships, for example, A and / or B, which can mean: A exists alone, A and B exist together, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0071] Hereinafter, the terms "first", "second" are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the embodiments, unless otherwise specified, the meaning of "multiple" is two or more than two.
[0072] In the description of the present application, the reference to "one embodiment" or "some embodiments" and the like means that the specific features, structures or characteristics described in connection with the embodiment are included in one or more embodiments of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in other some embodiments" and the like appearing in different places in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "include", "contain", "have" and their variants mean "include but not limited to", unless otherwise specifically emphasized.
[0073] In order to better understand the embodiments of the present application, first, some terms involved in the embodiments of the present application are explained below, so as to facilitate the understanding of those skilled in the art.
[0074] 1, trust circle and trusted electronic device
[0075] Through trusted authentication between two or more electronic devices, a trust relationship is established, and a trust circle is formed.
[0076] The electronic devices can be authenticated by any of the following methods, establish a trust relationship, and form a trust ring: 1) logging into the same account on two or more electronic devices, and the electronic devices under the same account trust each other, so that the two or more electronic devices form a 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 (NAS), etc. of the same user can be authenticated by logging into the account of the user, establish a trust relationship, and form a trust ring. 2) Two or more electronic devices can be authenticated by a private protocol, establish a trust relationship, and form a trust ring. 3) Two or more electronic devices can be authenticated by logging into the cloud, establish a trust relationship, and form a trust ring. It can be understood that the above-mentioned methods for constructing a trust ring are only used for illustration and do not constitute any limitation on the present application.
[0077] The electronic devices in the trust ring form a local area network through near field communication, and can synchronize data and realize device cooperation through the local area network. In the embodiments of the present application, the data synchronization includes but is not limited to file synchronization.
[0078] The electronic device that initiates a synchronization request in the trust ring can be referred to as a master device, and other electronic devices that have a trust relationship with the master device through trusted authentication are referred to as trusted electronic devices. For example, a mobile phone, a tablet computer, and a notebook computer form a trust ring, the mobile phone initiates a synchronization request in the trust ring, and the application synchronizes files in the mobile phone to the tablet computer and the notebook computer, so the mobile phone is the master device, and the tablet computer and the notebook computer are trusted electronic devices.
[0079] 2、Cross-end mounting access to files
[0080] The storage device transmits, shares, and accesses files between different operating systems and electronic devices.
[0081] 3、Trust ring application
[0082] The trust ring application represents an application program in the electronic devices in the trust ring. The user can set file backup, file synchronization, etc. through the trust ring application.
[0083] Exemplarily, the trust ring application can include a file management application, a settings 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, etc.
[0084] 4、Software Development Kit (SDK)
[0085] SDK is usually referred to as a collection of development tools that software engineers use when developing applications for a specific software package, software framework, hardware platform, operating system, etc. In other words, SDK is a collection of related documentation, examples, and tools that assist in the development of a certain type of application, which facilitates the creation of an application through compilers, debuggers, software frameworks, etc.
[0086] In the embodiments of the present application, the SDK can include a file synchronization SDK. The file synchronization SDK can be integrated in an application, such as a trusted ring application, thereby configuring the trusted ring application with the capability of file synchronization.
[0087] 5. Directory and folder
[0088] Directory and folder usually refer to the same concept, and are containers used to organize and store files and other directories / folders. In the embodiments of the present application, the two words are used interchangeably in different application scenarios, but they represent the same meaning and function.
[0089] 6. Water level synchronization
[0090] Water level synchronization is a concept in the field of real-time data processing, which is used to ensure the consistency and integrity of data in a distributed system. In the embodiments of the present application, water level synchronization is used to ensure the consistency and integrity of files in different electronic devices and different operating systems.
[0091] The above is a brief introduction to the terms involved in the embodiments of the present application, which will not be described again below.
[0092] The electronic devices in the trusted ring form a local area network through near field communication, and data synchronization can be performed through the local area network. For example, file synchronization can be performed between the electronic devices in the trusted ring.
[0093] Please refer to Figure 1 , Figure 1 is a system architecture diagram applicable to the method for processing data shown in the embodiments of the present application. As shown in Figure 1 , the electronic device 100, the electronic device 200, and the electronic device 300 establish a trusted relationship through trusted authentication, and form a trusted ring. It should be understood that the number of electronic devices included in the trusted ring can also be more or less than the number of electronic devices shown in Figure 1 , and the actual demand is for reference, and no limitation is made thereto.
[0094] In the embodiments of the present application, the electronic device 100, the electronic device 200, and the electronic device 300 can be mutually the master device and the trusted electronic device.
[0095] 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 examples, the following is described. For example, when the mobile phone initiates a synchronization request to the tablet computer and the notebook computer, and applies to synchronize files in the mobile phone to the tablet computer and the notebook computer, the mobile phone is the 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 apply to synchronize files in the mobile phone and the tablet computer to the notebook computer, the mobile phone and the tablet computer are the master devices, and the notebook computer is the trusted electronic device. This is only an example, and is not limited thereto.
[0096] Referring to Figure 2 , Figure 2 is a schematic diagram of another system architecture to which the method for processing data according to the embodiments of the present application is applicable. As shown in Figure 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 circle. Unlike the trust circle shown in Figure 1 , the electronic device 400 included in the trust circle shown in Figure 2 may be a NAS. In the embodiments of the present application, the mobile phone and / or the tablet computer initiates a synchronization request to the NAS, and applies to synchronize files in the mobile phone and / or the tablet computer to the NAS. The NAS can also access files across terminals, for example, the NAS can transmit and share files to the mobile phone and / or the tablet computer, and can also access files in the mobile phone and / or the tablet computer.
[0097] The following describes the application scenario of data synchronization between electronic devices in the trust circle with reference to the accompanying drawings.
[0098] The trust circle provided by the embodiments of the present application can include a mobile phone and a NAS, and the following is described taking the example of synchronizing files in the mobile phone to the NAS.
[0099] Referring to Figure 3 , Figure 3 is a schematic diagram of an application scenario of file synchronization according to the embodiments of the present application.
[0100] For example, a setting application in the mobile phone is opened, and the "System and updates" option is selected in the display interface corresponding to the setting application, and the mobile phone displays the interface shown in Figure 3 (a). The control 101 in the interface shown in Figure 3 (a) is clicked, that is, the "Backup and restore" option is clicked, and the mobile phone displays the interface shown in Figure 3 (b).
[0101] In Figure 3In the interface shown in (b), various data backup and recovery modes are shown, such as cloud backup, external storage, mobile phone assistant, etc. Among them, the cloud backup can be used to backup the whole machine data of the mobile phone to the cloud server, and when necessary, the whole machine data stored in the cloud server can also be recovered to the mobile phone through the cloud backup. The whole machine data can include gallery, contacts, short message, call record, memo, input method, spam blocking, wireless local area network (WLAN) setting, scene intelligence, mobile phone manager, clock, weather, camera, calendar, desktop icon layout, system setting, application program, chat record, browsing record, etc.
[0102] The external storage is used to connect the external storage device to backup and recover data. The external storage device can include an external storage card, a universal serial bus (USB) storage device, a NAS, etc.
[0103] The mobile phone assistant is used to connect the computer to backup and recover data.
[0104] In the embodiment of the present application, the files in the mobile phone are backed up to the NAS through the external storage. It is worth noting that synchronization also belongs to a backup method, and in the present application, the files in the mobile phone are also referred to as being synchronized to the NAS. In addition, it is also worth noting that the files and data in the present application refer to the same content, that is, the files in the mobile phone can include gallery, contacts, short message, call record, memo, input method, spam blocking, wireless local area network (WLAN) setting, scene intelligence, mobile phone manager, clock, weather, camera, calendar, desktop icon layout, system setting, application program, chat record, browsing record, etc.
[0105] Please refer to Figure 4 and Figure 5 , Figure 4 is a schematic diagram of the backup data based on the external storage shown in the embodiment of the present application, Figure 5 is a backup data process schematic diagram shown in the embodiment of the present application.
[0106] Exemplarily, clicking the control 102 in the interface shown in (b), that is, clicking the "external storage" option, the mobile phone displays the interface shown in (a) of Figure 3 Figure 4 Figure 4 The interface shown in (a) displays identification information for various external storage devices, such as external memory cards, USB storage, and shared folders. Specifically, the external memory card is used to back up data from the phone to the external memory card when it is detected; the USB storage is used to back up data from the phone to the USB drive when connected to a USB device; and the shared folder is used to back up data from the phone to the home NAS device when a shared folder on the same network is detected.
[0107] This example uses a shared folder to back up data from the phone to the NAS. For example, click... Figure 4 Control 103 in the interface shown in (a) is the option to click the "Shared Folder" option. The phone displays the following: Figure 4 The interface shown in (b) is as follows. At this time, the mobile phone discovers NAS storage devices on the same network through WLAN scanning, or the mobile phone discovers NAS storage devices in the trust ring. After the NAS storage device appears, the user can click to access and add shared folders under the NAS storage device.
[0108] For example, click Figure 4 Control 104 in the interface shown in (c) is used when the "Device Name" option is clicked; the phone then displays the following... Figure 5 The interface shown in (a) is shown in the image. Figure 5 The interface shown in (a) displays the device name of the NAS storage device, the used storage space of the NAS storage device (1.58TB used) and the total storage space (e.g., 3.92TB).
[0109] exist Figure 5 The interface shown in (a) also displays an automatic backup control 105, a toggle control 106, and a backup data item selection control 107. The toggle control 106 is used to enable or disable the automatic backup function. Figure 5 The scenario shown in (a) is when the automatic backup function is enabled.
[0110] For example, with the automatic backup function enabled, users can set the automatic backup cycle according to their needs. For instance, they can set the automatic backup every day when the phone screen is off, or every seven days when the phone screen is off.
[0111] The select backup data item control 107 is used by the user to select the data items that need to be backed up. For example, clicking... Figure 5 In the interface shown in (a), the control 107 for selecting backup data items, i.e., clicking the "Automatically back up data items" option, will display the following on the phone: Figure 5 The interface shown in (b) is shown in the middle.
[0112] exist Figure 5In the interface shown in (b), the full selection control 108 and the start backup control 109 are displayed. The full selection control 108 can be checked to select all the data items to be backed up, such as the music, pictures, videos, contacts, documents, system settings and the like shown in (b). It should be understood that this is only an exemplary description, and the user can also check one or more data items to be backed up according to his own needs. Figure 5 In the interface shown in (b), the music, pictures, videos, contacts, documents, system settings and the like are shown. It should be understood that this is only an exemplary description, and the user can also check one or more data items to be backed up according to his own needs.
[0113] After selecting the data items to be backed up, the start backup control 109 in the interface shown in (b) is clicked, that is, the "start backup" option is clicked, and the mobile phone displays the interface shown in (c). Figure 5 After selecting the data items to be backed up, the start backup control 109 in the interface shown in (b) is clicked, that is, the "start backup" option is clicked, and the mobile phone displays the interface shown in (c). Figure 5 The mobile phone performs data preparation, such as calculating the number of items and the data size corresponding to each data item to be backed up, and displays the interface shown in (c). Figure 5 The mobile phone performs data preparation, such as calculating the number of items and the data size corresponding to each data item to be backed up, and displays the interface shown in (c).
[0114] In the embodiments of the present application, the distributed management service is used to manage each electronic device in the trust circle, so that the data can be stored and accessed between different electronic devices (such as mobile phones, tablet computers, notebook computers, NAS and the like), different operating systems (such as the Android system, the IOS operating system, the Symbian operating system, the Black Berry operating system, the Linux operating system, the Windows operating system and the like), cross-device and cross-system data storage and access are realized, and the data access channel of near field communication between electronic devices is opened.
[0115] The above describes the application scenario of file synchronization in combination with user operations, and the specific process of file synchronization between electronic devices in the trust circle is described in combination with the drawings.
[0116] The trust circle provided by the embodiments of the present application can include a mobile phone and a personal computer (PC), and the PC can include a desktop computer, a notebook computer, a small notebook computer, a tablet computer and an ultrabook, and the like. Taking the example of synchronizing files in the mobile phone to the tablet computer, the process is described.
[0117] Please refer to Figure 6 , Figure 6 The process of file synchronization shown in the embodiments of the present application is shown in the process diagram.
[0118] In S101, the trust circle application acquires a file synchronization request and calls a file synchronization SDK.
[0119] The trust circle application represents an application program in an electronic device within the trust circle. A user can set up functions such as file backup, file synchronization, or turn off functions such as file backup, file synchronization through the trust circle application.
[0120] In the embodiments of the present application, the trust circle application can include a file management application, a settings 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.
[0121] The file synchronization SDK is pre-integrated in the trust circle application, facilitating the trust circle application to create a shared directory / shared folder by calling the file synchronization SDK.
[0122] The file synchronization request is used to request to synchronize a file in an electronic device to which the trust circle application belongs, to at least one trusted electronic device included in the trust circle. For example, the electronic device to which the trust circle application belongs is a mobile phone, and the trusted electronic device included in the trust circle is a tablet computer. The file synchronization request is used to request to synchronize the file in the mobile phone to the tablet computer.
[0123] The file synchronization request can be triggered by the electronic device to which the trust circle application belongs, or by the trusted electronic device. For example, the trust circle application installed on the mobile phone receives an operation of a user setting to turn on the file synchronization function, triggering the file synchronization request. Alternatively, the trusted electronic device initiates a file synchronization request to the electronic device to which the trust circle application belongs. For example, the tablet computer initiates a file synchronization request to the mobile phone, and the mobile phone receives the file synchronization request.
[0124] For example, when the trust circle application obtains the file synchronization request, the trust circle application calls the file synchronization SDK by using pre-written code in the trust circle application.
[0125] S102, the file synchronization SDK calls the file synchronization service module to create a shared directory / shared folder.
[0126] For example, the file synchronization service module is deployed in the application framework layer and is a software component specially designed in the present application to synchronize files between different electronic devices and different operating systems.
[0127] In the embodiments of the present application, the shared directory can be represented by a REPO directory, and the electronic devices within the trust circle can share the REPO directory. The REPO directory can include a file path, a scanning start time, a scanning time interval, REPO identification information, an electronic device name, file synchronization configuration information, a callback function of the file path, and the like.
[0128] The file path refers to a path corresponding to the file to be synchronized, i.e., a path of the file in the trusted electronic device. For example, the user wants to synchronize the pictures on the mobile phone to the tablet computer, selects the path corresponding to the gallery on the mobile phone, or selects the directory corresponding to the gallery on the mobile phone. The selected path or the selected directory is the file path.
[0129] The scanning start time is the time when the electronic device starts to scan the file path. Generally, the time when the electronic device starts to scan the file path for the first time is determined according to the time when the user sets to start the file synchronization function for the first time. For example, the user selects to start to synchronize the file immediately when setting to start the file synchronization function for the first time. Then, the electronic device starts to scan the file path immediately, i.e., the scanning start time is the time when the user starts the file synchronization function.
[0130] The time when the electronic device starts to scan the file path for the second 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 synchronize the file automatically every day or every seven days. Then, the electronic device scans the file path every day or every seven days after scanning the file path for the first time.
[0131] The REPO identification information is an identifier (ID) of the REPO, which is used to uniquely identify the REPO of the electronic device.
[0132] The file synchronization configuration information can include the file synchronization times, the file synchronization version, the name of the trusted electronic device, the REPO identification information of the trusted electronic device, the file path of the trusted electronic device, and the filtered file.
[0133] The file synchronization version is used to indicate that the synchronized file has been changed. For example, the file synchronization version is recorded as 1.0 when the file synchronization is performed for the first time. When the file synchronization is performed for the second time, if the file has been changed, the file synchronization version is recorded as 1.1. When the file synchronization is performed for the third time, if the file has been changed, the file synchronization version is recorded as 1.2, and so on.
[0134] The REPO identification information of the trusted electronic device is an ID of the REPO of the trusted electronic device, which 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 can perform file synchronization.
[0135] The file path of the trusted electronic device refers to a path of the file to be synchronized, i.e., a path of the file synchronized from the electronic device. For example, the user wants to synchronize the pictures on the mobile phone to a specified path in the tablet computer. The specified path is the file path of the trusted electronic device.
[0136] The filtered file is a file that does not need to be synchronized. In the embodiment of the present application, the filtered file can not be scanned, the power consumption of the electronic device can be reduced, the time for scanning the file in the file synchronization process can be effectively reduced, and the file synchronization efficiency can be improved.
[0137] Exemplarily, the file synchronization SDK calls the file synchronization service module, and the file synchronization service module creates a shared directory / shared folder by using an application programming interface (API) function or method provided by the file synchronization SDK, for example, creates a REPO directory.
[0138] In S103, the file synchronization service module performs data persistence processing on the shared directory / shared folder.
[0139] The data persistence processing refers to long-term storage of data on a storage medium that can be persistently saved, so that the data can still be accessed after the application or the operating system is restarted.
[0140] In the embodiment of the present application, the REPO directory can be stored in a local database of the mobile phone that can be persistently saved. In this way, after the user sets the file synchronization function, even if the mobile phone is restarted or the trust circle application is restarted, the relevant information of the file synchronization function set by the user can be read from the local database, and it is ensured that the relevant information of the REPO directory is not lost. For the user, the relevant information of the file synchronization function only needs to be set once, and the file synchronization function can be applied all the time, without the need to set the relevant information of the file synchronization function again after the mobile phone is restarted or the trust circle application is restarted, thereby improving the user experience.
[0141] The above steps S101 to S103 describe a scenario in which the electronic device (for example, a mobile phone) creates a shared directory / shared folder, for example, a REPO directory, after obtaining a file synchronization request. In a possible implementation manner, the electronic device (for example, a mobile phone) can also create a shared directory / shared folder in advance, for example, a REPO directory, that is, the electronic device (for example, a mobile phone) creates a REPO directory before obtaining a file synchronization request. For example, the trust circle application calls the file synchronization SDK, the file synchronization SDK calls the file synchronization service module to create a REPO directory, and the file synchronization service module performs data persistence processing on the REPO directory.
[0142] This way of creating a REPO directory in advance in the electronic device is beneficial to subsequent file synchronization of the electronic device in the trust circle by directly using the REPO directory, thereby improving the file synchronization efficiency.
[0143] Optionally, in a possible implementation manner, the trusted electronic device can create the shared directory / shared folder, for example, create the REPO directory, by using a method similar to the method in steps S101 to S103 described above. As shown in FIG. 10, the method specifically includes the following steps. Figure 6
[0144] S201, the trust ring application in the trusted electronic device acquires a file synchronization request and calls a file synchronization SDK.
[0145] S202, the file synchronization SDK calls a file synchronization service module in the trusted electronic device to create a shared directory / shared folder.
[0146] S203, the file synchronization service module performs data persistence processing on the shared directory / shared folder.
[0147] For the description of steps S201 to S203, refer to the specific description in steps S101 to S103 described above, which will not be repeated here.
[0148] The steps S201 to S203 described above describe the scenario that the trusted electronic device (for example, a tablet computer) creates a shared directory / shared folder, for example, creates a REPO directory, when the trusted electronic device acquires a file synchronization request. In a possible implementation manner, the trusted electronic device (for example, a tablet computer) can also create a shared directory / shared folder in advance, for example, create a REPO directory in advance, that is, the trusted electronic device (for example, a tablet computer) creates a REPO directory before acquiring a file synchronization request.
[0149] This method of creating a REPO directory in advance in the trusted electronic device is beneficial to the electronic device in the subsequent trust ring to directly use the REPO directory for file synchronization, thereby improving the efficiency of file synchronization.
[0150] S104, share the REPO directory with the trusted electronic device.
[0151] For example, the electronic device (for example, a mobile phone) determines a to-be-synchronized file according to a file synchronization request, scans a file path in the electronic device (for example, a mobile phone) based on the to-be-synchronized file, and records a file synchronization version for each scanning result.
[0152] For example, the file path in the electronic device (such as a mobile phone) is scanned based on the to-be-synchronized file for the first time, and a file synchronization version 1.0 is recorded for the first scanning result; the file path in the electronic device (such as a mobile phone) is scanned based on the to-be-synchronized file for the second time, and it is detected that the to-be-synchronized file has changed compared with the first time, and a file synchronization version 1.1 is recorded for the second scanning result; the file path in the electronic device (such as a mobile phone) is scanned based on the to-be-synchronized file for the third time, and it is detected that the to-be-synchronized file has not changed compared with the second time, and a file synchronization version 1.1 is recorded for the third scanning result, and so on.
[0153] The electronic device (such as a mobile phone) shares the recorded file synchronization version each time with the trusted electronic device (such as a tablet computer). For example, the electronic device (such as a mobile phone) records the file synchronization version each time in the REPO directory and shares it with the trusted electronic device (such as a tablet computer), and the trusted electronic device (such as a tablet computer) can read the change of the file synchronization version from the REPO directory, thereby quickly determining the change of the synchronized file.
[0154] S105, REPO directory metadata synchronization processing is performed with the trusted electronic device.
[0155] Metadata is used to describe data attributes, and REPO directory metadata refers to file paths, scanning start time, scanning time interval, REPO identification information, electronic device name, file synchronization configuration information and the like included in the REPO directory.
[0156] The REPO directory metadata synchronization can be understood as that the electronic device (such as a mobile phone) and the trusted electronic device (such as a tablet computer) perform water level synchronization based on the REPO directory. For example, the electronic device (such as a mobile phone) synchronizes the file paths, scanning start time, scanning time interval, REPO identification information, electronic device name, file synchronization configuration information and the like included in the REPO directory with the trusted electronic device (such as a tablet computer), thereby providing guarantee for consistency and integrity of subsequent files in different electronic devices and different operating systems.
[0157] S106, the file synchronization service module listens to the file system.
[0158] The file synchronization service module can include a listening scanning management module, which is used to listen to and scan the file system in the electronic device (such as a mobile phone).
[0159] For example, the mobile phone determines the to-be-synchronized file according to the file synchronization request, and listens to and scans the file path of the to-be-synchronized file in the file system. For example, the user wants to synchronize the pictures on the mobile phone to the tablet computer, and listens to and scans the path corresponding to the gallery on the mobile phone.
[0160] When the change of the file to be synchronized is monitored or scanned, such as the addition, deletion, modification, etc. of the file to be synchronized, the change is notified to the file synchronization service module.
[0161] For example, the file to be synchronized is a picture, and any application related to the picture discovers a change, which will affect the file to be synchronized. For example, the camera application, social application, sharing application, etc. add, delete, and / or modify the picture, and the corresponding change is notified to the file synchronization service module.
[0162] 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 can include the addition, deletion, modification, etc. of the file, and the operation time corresponding to each operation.
[0163] For example, the file change record is stored in the local database of the phone that can be persistently saved, so that even if the phone is restarted, or the trusted ring application is restarted, or any application related to the file to be synchronized is restarted, the file change record can be read from the local database.
[0164] S107, the file synchronization service module reads the file change record from the local database.
[0165] For example, the file synchronization service module reads the file change record from the local database periodically according to the file synchronization period set by the user. For example, the electronic device monitors or scans the file system once, and the file synchronization service module reads the file change record from the local database once.
[0166] S108, file metadata synchronization processing is performed with the trusted electronic device.
[0167] File metadata refers to file name, belonging to electronic device, file size, file addition time, file deletion time, file modification time, etc.
[0168] File metadata synchronization can be understood as the electronic device (such as a mobile phone) synchronizing file metadata with the trusted electronic device (such as a tablet computer). In this implementation, the file metadata is synchronized with the trusted electronic device first, and the file content can be directly synchronized later, which improves the file synchronization efficiency and reduces errors.
[0169] It should be understood that the electronic device and the trusted electronic device perform file metadata synchronization processing, 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 its own file metadata. Figure 6As shown, the comparison method specifically includes:
[0170] S204, the trusted electronic device performs file metadata comparison processing.
[0171] 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.
[0172] For example, the tablet computer uses the file synchronization service module to compare the file metadata in its own file system one by one with the file metadata sent by the mobile phone. If the comparison result is consistent, the file metadata recorded in the tablet computer is maintained; if the comparison result is inconsistent, the file metadata sent by the mobile phone is used as the standard, i.e. the file metadata in the tablet computer is modified to the file metadata sent by the mobile phone.
[0173] In this implementation, the file metadata in the electronic device is first synchronized with the file metadata in the trusted electronic device, and then the file content can be directly synchronized, which improves the file synchronization efficiency and is less prone to errors.
[0174] Optionally, in a possible implementation, after the trusted electronic device performs file metadata comparison processing, the electronic device sends the file metadata for data persistence processing. For example, the modified file metadata is stored in a local database.
[0175] S109, file content synchronization processing is performed with the trusted electronic device.
[0176] 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; if the file to be synchronized is music, the file content is the audio itself.
[0177] For example, the file synchronization service module in the electronic device reads the file content from the file system and sends the read file content to the trusted electronic device. Correspondingly, the trusted electronic device needs to save the file content sent by the electronic device. For example, Figure 6 As shown, the saving method specifically includes:
[0178] S205, the trusted electronic device performs file content file landing processing.
[0179] File spooling generally refers to writing data from a temporary storage area to a permanent storage device. In the embodiments of the present application, the trusted electronic device saves the file content sent by the electronic device into a local database of the trusted electronic device. Optionally, in one possible implementation, the trusted electronic device saves the file content sent by the electronic device into a file system, and then saves the file content in the file system into the local database. In this way, even if the trusted electronic device is restarted or the trust ring application is restarted, the synchronized file will not be affected and can still be read from the local database.
[0180] It should be noted that the above description of the specific process of file synchronization between electronic devices in the trust ring is described by taking the example of synchronizing files in a mobile phone to a tablet computer, and thus the method executed by the mobile phone is mainly described. It can be understood that when files in the tablet computer need 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.
[0181] It can be understood that in the embodiments of the present application, although the Android operating system is taken as an example for description, the basic principle is also applicable to electronic devices based on the IOS, Symbian, Black Berry, Linux, Windows, and other operating systems.
[0182] In the embodiments of the present 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 the core service for file synchronization between electronic devices in the trust ring. Exemplarily, the file synchronization service module completes the perception of file changes and the generation of file metadata by listening to and scanning the local file system. Meanwhile, the trust ring self-discovery and self-networking capability provided by the system can enable the electronic device to quickly discover the surrounding devices, and enable the electronic device to share the REPO directory, synchronize the REPO metadata, synchronize the file metadata, and synchronize the file content with the trusted electronic device in the trust ring, thereby realizing cross-device and cross-system data storage and access, and opening up the data access channel of near field communication between electronic devices.
[0183] In the process of file synchronization between electronic devices in a trust circle, the files in the electronic devices need to be monitored and scanned, or the file paths / file directories corresponding to the files need to be monitored and scanned. When multiple file paths / file directories need to be monitored and scanned, even if there is a containing relationship between the multiple file paths / file directories, each file path / file directory still needs to be monitored and scanned in the related technology. Each monitoring needs to create a corresponding monitoring task, or each monitoring needs to start a corresponding monitoring thread, which increases the number of monitoring threads started and the number of times of scanning file paths / file directories, and finally leads to low file synchronization efficiency and high power consumption of the electronic device.
[0184] For ease of understanding, please refer to Figure 7 , Figure 7 A file directory diagram is shown for the embodiments of the present application.
[0185] As Figure 7 indicated, each letter represents a file directory, and each file directory corresponds to a file path. By scanning the file path, the file pointed to by the file path and the file content of the file can be found.
[0186] Exemplarily, the file directory associated with the scanning task is determined according to the file synchronization request. It can be understood in a simple way that the file path corresponding to which file directory needs to be monitored and scanned is determined according to the file synchronization request, that is, which file directory is associated with the scanning task is confirmed.
[0187] As Figure 7 indicated, it is assumed that the user wants to synchronize the files corresponding to the file directories D, D1, D2 and D221 in the mobile phone to the tablet computer. Therefore, when setting the file synchronization function, the file directories D, D1, D2 and D221 are specified. Then, when the mobile phone obtains the file synchronization request, the scanning tasks corresponding to the file directories D, D1, D2 and D221 are determined according to the file synchronization request, and each scanning task corresponds to a file path.
[0188] And we know that there is usually a containing or contained relationship between directories. For example Figure 7As shown, in addition to the root directory " / ", each directory has a parent directory, and each directory can also be a subdirectory in different scenarios. For example, the parent directories of file directory A and file directory E are both the root directory " / ", and file directory A and file directory E are both subdirectories of the root directory " / ". The parent directory of file directory D111 is file directory D11, the parent directory of file directory D11 is file directory D1, the parent directory of file directory D1 is file directory D, and the parent directory of file directory D is the root directory " / ". Correspondingly, file directory D111 is a subdirectory of file directory D11, file directory D111 and file directory D11 are subdirectories of file directory D1, file directory D111, file directory D11 and file directory D1 are subdirectories of file directory D, and file directory D111, file directory D11, file directory D1 and file directory D are subdirectories of the root directory " / ". The same applies to file directories D221, D22 and D2, which will not be described here.
[0189] When file directories D, D1, D2 and D221 each correspond to a scanning task, the file paths corresponding to file directories D, D1, D2 and D221 need to be monitored and scanned. Since there is a containing relationship between file directories D and D1, for the scanning task corresponding to file directory D1, all scanned files under file directory D1 and its subdirectories (such as file directory D11 and file directory D111) need to be notified to the scanning task corresponding to file directory D; for the scanning task corresponding to file directory D, all scanned files under file directory D and its subdirectories (such as file directory D111, file directory D11 and file directory D1) need to be notified to the scanning task corresponding to file directory D. The same applies to file directories D, D2 and D221, which will not be described here.
[0190] In this case, even if all scanned files under file directory D1 and its subdirectories have been notified to the scanning task corresponding to file directory D when the scanning task corresponding to file directory D1 is completed, it is still necessary to monitor and scan the file paths corresponding to file directories D and its subdirectories when the scanning task corresponding to file directory D is completed. This is equivalent to monitoring and scanning the file paths corresponding to file directory D1 and its subdirectories multiple times, and each monitoring requires creating a corresponding monitoring task, or in other words, each monitoring requires starting a corresponding monitoring thread, resulting in an increase in the number of monitoring threads started, an increase in the number of times the file paths are scanned, repeated monitoring and scanning, and ultimately low file synchronization efficiency and high power consumption of the electronic device.
[0191] Therefore, the embodiment of the present application provides a method for processing data, which is applied to an electronic device, the trust circle in which the electronic device is located further comprises at least one trusted electronic device, and files in the electronic device can be synchronized to the at least one trusted electronic device, and the method comprises the following steps.
[0192] In this implementation, after the file path with the containing relationship is determined, the scanning tasks corresponding to the file path with the containing relationship are merged. Since the sub-file path in the file path with the containing relationship, the scanning result corresponding to the sub-file path can be notified to the scanning task corresponding to the parent file path. Thus, even if the scanning tasks are merged, the scanning tasks corresponding to the file path with the containing relationship can be successfully completed. Moreover, since the scanning tasks are merged, in the process of executing the merged scanning tasks, multiple scanning of the same file path can be avoided, thereby effectively reducing the scanning times, reducing the workload of repeated scanning, reducing the power consumption of the electronic device, optimizing the resource allocation in the system, accelerating the entire file synchronization process, and improving the subsequent file synchronization efficiency.
[0193] The method for processing data provided by the embodiment of the present application is suitable for any near field communication scene in which files need to be listened to and scanned.
[0194] The method for processing data provided by the embodiment of the present application is suitable for any near field communication scene in which files need to be listened to and scanned.
[0195] Please refer to Figure 8 , Figure 8 The flowchart of the method for processing data provided by the embodiment of the present application is shown. The method comprises the following steps.
[0196] S301, a file synchronization request is obtained.
[0197] The trust relationship between two or more electronic devices is established through trusted authentication, and a trust circle is formed. In the embodiment of the present application, the trust circle in which the electronic device is located further comprises at least one trusted electronic device, and the files in the electronic device can be synchronized to the trusted electronic device in the trust circle.
[0198] Exemplarily, the file synchronization request can be triggered by the electronic device or by the trusted electronic device. In a general sense, the file synchronization request can be triggered by the electronic device actively or by the trusted electronic device passively.
[0199] In one example, the trusted ring application installed on the mobile phone triggers the file synchronization request when receiving an operation of the user setting to turn on the file synchronization function. For example, the user wants to synchronize the pictures on the mobile phone to the tablet computer. After selecting the pictures in the gallery through the trusted ring application and selecting the "start synchronization" option, the file synchronization request is triggered, and the mobile phone sends the selected pictures to the tablet computer. It can be understood that the user can also specify the storage location of the tablet computer for storing the pictures when selecting the pictures in the gallery.
[0200] In another example, the user wants to synchronize the pictures on the mobile phone to the tablet computer, and the tablet computer initiates a file synchronization request to the mobile phone. The file synchronization request carries indication information of the pictures to be synchronized. The mobile phone receives the file synchronization request and synchronizes the pictures to the tablet computer according to the indication information of the pictures.
[0201] Optionally, in a possible implementation manner, the file synchronization request can be triggered automatically by the electronic device. For example, the user sets to synchronize the files automatically once every day or once every seven days, and the mobile phone triggers the file synchronization request automatically once every day after the first synchronization of the files. For another example, the user sets to start the automatic synchronization of the files when the time reaches a preset time point (e.g., 8:00, 12:00, 23:00, etc.), and the mobile phone triggers the file synchronization request automatically when monitoring that the current time reaches the preset time point. This is only an example and is not limited thereto.
[0202] Optionally, in another possible implementation manner, the trusted electronic device in the trusted ring can also trigger the file synchronization request automatically and send the file synchronization request to the electronic device after each triggering. For details, refer to the related description of the electronic device, which will not be repeated here.
[0203] S302, determine a plurality of scanning tasks corresponding to the file synchronization request.
[0204] The file synchronization request is used to trigger the electronic device to synchronize the files that the user wants to synchronize to the trusted electronic device. In some description manners of the embodiments of the present application, the files that the user wants to synchronize are also referred to as the to-be-synchronized files.
[0205] Each scanning task corresponds to a file path, and each file path corresponds to a file directory. The file path can be scanned to find the file pointed to by the file path and the file content of the file.
[0206] In the embodiments of the present application, the scanning task can include monitoring and scanning of the file path.
[0207] It can be understood that the user wants to synchronize a certain file, and the electronic device needs to monitor and scan the certain file, and the file synchronization request is generated based on the file that the user wants to synchronize. Therefore, the file synchronization request can carry the corresponding scanning task, or the multiple scanning tasks corresponding to the file synchronization request can be determined according to the file synchronization request.
[0208] For ease of understanding, please refer to Figure 9 , Figure 9 Another file directory diagram is shown in the embodiments of the present application. As shown in Figure 9 , each letter represents a file directory, and the letters in the gray background represent that the file path corresponding to the file directory is associated with a scanning task, that is, the letters in the gray background represent that the file directory corresponds to a scanning task. For example, according to the file synchronization request, it is determined that the file directories A, E, D, D1, D2, and D221 each correspond to a scanning task, and the file paths corresponding to the file directories A, E, D, D1, D2, and D221, that is, the file paths that each scanning task needs to monitor and scan, are determined.
[0209] S303, determining an associated file path in the multiple file paths.
[0210] Exemplarily, the associated file path is a file path having a containing relationship, and the file path having a containing relationship includes at least one child file path and one parent file path. It can be understood that the containing relationship is divided into containing and being contained, and in different scenarios, for the same file path, it can be a child file path and be contained in another parent file path, or it can be a parent file path and contain another child file path. The actual situation is used as the criterion, and no limitation is made in this regard.
[0211] Since each file directory has a corresponding file path, and the multiple file paths have a containing relationship, correspondingly, the multiple file directories also have a containing relationship.
[0212] Exemplarily, the multiple file paths corresponding to the multiple scanning tasks can be traversed by means of a graph structure, a graph algorithm, a tree, a graph database, writing a function, etc., to determine the file paths having a containing relationship in the multiple file paths.
[0213] For ease of description, in the embodiments of the present application, the letters of the file directories represent the file paths corresponding to the file directories, for example, the file directories A, E, D, D1, D2, and D221 correspond to the file paths A, E, D, D1, D2, and D221, respectively.
[0214] In combination withFigure 9 The parent file path of the file path A and the file path E is “ / ”, and the file path A and the file path E are also sub-file paths of “ / ”. The sub-file path of the file path D is the file path D1, and the parent file path of the file path D is “ / ”. The parent file path of the file path D2 is the file path D, and the sub-file path of the file path D2 is the file path D22, and the parent file path of the file path D221 is the file path D22.
[0215] The file paths A, E, D, D1, D2 and D221 are associated with scanning tasks, and the file paths A, E, D, D1, D2 and D221 need to be monitored and scanned. Among the file paths A, E, D, D1, D2 and D221, there is a containing relationship between the file paths D and D1, and there is a containing relationship between the file paths D, D2 and D221, that is, the file paths D and D1 are associated file paths, and the file paths D, D2 and D221 are associated file paths.
[0216] For example, for the associated file paths D and D1, all the scanned files under the file path D1 and its sub-file paths (such as the file path D11 and the file path D111) need to be notified to the scanning task corresponding to the file path D in addition to the scanning task corresponding to the file path D1.
[0217] For example, for the associated file paths D, D2 and D221, all the scanned files under the file path D221 need to be notified to the scanning tasks corresponding to the file paths D2 and D in addition to the scanning task corresponding to the file path D221; and all the scanned files under the file path D2 and its sub-file paths (such as the file path D22 and the file path D221) need to be notified to the scanning task corresponding to the file path D in addition to the scanning task corresponding to the file path D2.
[0218] For the above associated file paths D and D1, when the scanning task corresponding to the file path D is completed, the file path D and all its sub-file paths (such as the file path D1, the file path D11 and the file path D111) also need to be monitored and scanned. That is, in the process of completing the scanning tasks corresponding to the associated file paths D and D1, the file path D1 and its sub-file paths are repeatedly monitored and scanned, which increases the number of threads for starting monitoring and the number of times of scanning file paths, and finally leads to low file synchronization efficiency and high power consumption of the electronic device. Therefore, the method for processing data provided in the embodiments of the present application combines the scanning tasks corresponding to the associated file paths. The associated file paths D, D2 and D221 are the same, and details are not repeated here.
[0219] S304, merge the scan tasks corresponding to the associated file paths.
[0220] Exemplarily, at least two scan tasks corresponding to the associated file paths are merged into one scan task. Taking the associated file paths D and D1 as examples, for example, the scan task corresponding to the file path D is recorded as ScanTask1, the scan task corresponding to the file path D1 is recorded as ScanTask2, and the scan tasks corresponding to the file paths D and D1 are merged to obtain a target scan task ScanTask2. When the scan task ScanTask2 is completed, all the scanned files under the file path D1 and its sub-file paths will notify the scan task corresponding to the file path D in addition to the scan task corresponding to the file path D1, so that the scan task corresponding to the file path D is also completed at the same time when the scan task ScanTask2 is completed. At the same time, because the scan tasks are merged, in the process of executing the merged scan task, multiple scans on the same file path can be avoided, thereby effectively reducing the number of scans, i.e., reducing the workload of repeated scanning, reducing the power consumption of the electronic device, optimizing the resource allocation in the system, speeding up the entire file synchronization process, and improving the subsequent file synchronization efficiency.
[0221] In the implementation manner described above, after the file paths with the containing relationship are determined, the scan tasks corresponding to the file paths with the containing relationship are merged. Because the sub-file paths in the file paths with the containing relationship will notify the scan task corresponding to the parent file path, even if the scan tasks are merged, the scan tasks corresponding to the file paths with the containing relationship can be ensured to be completed successfully. Moreover, because the scan tasks are merged, in the process of executing the merged scan task, multiple scans on the same file path can be avoided, thereby effectively reducing the number of scans, i.e., reducing the workload of repeated scanning, reducing the power consumption of the electronic device, optimizing the resource allocation in the system, speeding up the entire file synchronization process, and improving the subsequent file synchronization efficiency.
[0222] Optionally, in a possible implementation manner, the step S304 can further include steps S3041 and S3042, and the details are as follows.
[0223] Please refer to Figure 10 , Figure 10 Another flowchart of a method for processing data shown in the embodiments of the present application.
[0224] The method includes:
[0225] S3041, obtaining at least two scan time intervals corresponding to the associated file paths.
[0226] The scanning time interval is determined according to the file synchronization period set by the user, and different file paths correspond to different scanning time intervals. For example, the user sets to synchronize the files corresponding to file path D once every 120 minutes and to synchronize the files corresponding to file path D1 once every 60 minutes, that is, the scanning time interval corresponding to file path D is 120 minutes, and the scanning time interval corresponding to file path D1 is 60 minutes.
[0227] In one example, the scanning time interval corresponding to each file path can be carried in the file synchronization request, and the scanning time interval corresponding to each file path in the associated file path can be obtained in the file synchronization request.
[0228] In another example, the scanning time interval corresponding to each file path in the associated file path can be obtained from a pre-created REPO directory.
[0229] S3042, merge the at least two scanning tasks corresponding to the associated file paths into a target scanning task, and set the target scanning time interval of the target scanning task according to the at least two scanning time intervals.
[0230] The target scanning time interval is greater than or equal to the smallest scanning time interval in the at least two scanning time intervals and less than the largest scanning time interval in the at least two scanning time intervals.
[0231] Exemplarily, the at least two scanning tasks corresponding to the associated file paths are merged into a target scanning task. Taking the associated file paths D and D1 as examples, for example, the scanning task corresponding to file path D is recorded as ScanTask1, and the scanning time interval corresponding to ScanTask1 is 120 minutes. The scanning task corresponding to file path D1 is recorded as ScanTask2, and the scanning time interval corresponding to ScanTask2 is 60 minutes. When ScanTask2 is set, the scanning tasks corresponding to file path D and file path D1 are merged, and the target scanning time interval is used as the scanning time interval after the merging. For example, the scanning tasks corresponding to file path D and file path D1 are merged to obtain the target scanning task ScanTask2, and the target scanning time interval corresponding to the target scanning task is 60 minutes. Subsequently, the scanning start time of each file path is set according to the merged target scanning time interval.
[0232] Optionally, the target scanning time interval can also be set as the scanning time interval of each scanning task corresponding to the associated file path, so that changes in the files corresponding to each file path can be found in time. For example, the target scanning time interval is set as the scanning time interval corresponding to ScanTask1, and then ScanTask1 is completed at the target scanning time interval. For example, the file path D is monitored and scanned every 60 minutes thereafter, so that changes in the files corresponding to the file path D can be found in time.
[0233] In the implementation manner described above, since the scanning tasks are combined, in the process of executing the combined scanning task, multiple scanning of the same file path can be effectively avoided, so that the number of scanning is effectively reduced, i.e., the workload of repeated scanning is reduced, the power consumption of the electronic device is reduced, the resource allocation in the system is optimized, the entire file synchronization process is accelerated, and the subsequent file synchronization efficiency is improved.
[0234] Optionally, in a possible implementation manner, the method for processing data provided by the embodiment of the present application can further include: scanning the file path corresponding to the target scanning task according to the target scanning time interval to obtain a scanning file.
[0235] The scanning file is used for synchronization to at least one trusted electronic device.
[0236] Exemplarily, the file synchronization service module in the electronic device can include an REPO management module, a monitoring and scanning management module, and a timer. The REPO management module can include an REPO directory, and the REPO management module can be used to manage the REPO directory.
[0237] The determined file path corresponding to the target scanning task and the target scanning time interval of the target scanning task can be stored in the REPO directory.
[0238] The timer can set the scanning start time of each time of the target scanning task according to the target scanning time interval. When the current time reaches the scanning start time, the timer triggers the monitoring and scanning management module to start scanning. The monitoring and scanning management module finds the file path corresponding to the target scanning task, scans the file path corresponding to the target scanning task, obtains a scanning file, and synchronizes the scanning file to the trusted electronic device in the trust circle. For example, every 60 minutes, the file path corresponding to the target scanning task is found, the file path corresponding to the target scanning task is monitored and scanned, and the corresponding scanning file is obtained.
[0239] In this implementation manner, the file path corresponding to the target scanning task is scanned purposefully without considering other file paths, the scanning efficiency is improved, the entire file synchronization process is accelerated, and the subsequent file synchronization efficiency is improved.
[0240] Optionally, in a possible implementation manner, the embodiment of the present application further provides a method for scanning files, please refer to Figure 11 , Figure 11 A flowchart for scanning files is shown in the embodiment of the present application. The method comprises:
[0241] S401, obtaining a to-be-scanned list.
[0242] The to-be-scanned list comprises an associated file path, a file path not associated with a scanning task, and a non-associated file path associated with a scanning task. It can be understood that the to-be-scanned list comprises all file paths.
[0243] In one example, the to-be-scanned list is included in a pre-created REPO directory, and the to-be-scanned list can be directly obtained from the REPO directory. In another example, the REPO directory pre-created includes various file paths, and the to-be-scanned list can be generated according to the file paths included in the REPO directory.
[0244] Taking the file directory shown in Figure 9 as an example, the to-be-scanned list can comprise file paths corresponding to file directories A, E, D, D1, D11, D111, D2, D21, D22, D221, D23, D3, and the root directory “ / ”. Among them, the file paths corresponding to file directories A and E are non-associated file paths associated with a scanning task, that is, file directories A and E correspond to a scanning task respectively, but the file paths corresponding to file directories A and E are not associated file paths; the file paths corresponding to file directories D and D1 are associated file paths, and the file paths corresponding to file directories D, D2, and D221 are also associated file paths; the file paths corresponding to file directories D11, D111, D21, D22, D23, D3, and the root directory “ / ” are file paths not associated with a scanning task.
[0245] S402, according to a target scanning time interval, scanning each file path in the to-be-scanned list, and when any file path in the associated file path is scanned, obtaining a scanning result of the any file path.
[0246] The scanning result can comprise files, file names, file quantities, file sizes, file creation times, file last modification times, file last access times, file types, file permissions (such as read-write permissions, write permissions, execution permissions, etc.), file owners, 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.), file system information, file versions, file extension attributes (such as custom tags), relative paths, etc. obtained by scanning the any file path.
[0247] The file can include a text file, a document file, an image file, an audio file, a video file, a compressed file, an encrypted file, an executable file, a webpage file, etc.
[0248] Exemplarily, the listening scanning management module scans each file path in the to-be-scanned list in turn in a target scanning time interval. It should be understood that each node in the file path represents a directory level, and the nodes are usually arranged in an order from top to bottom. For example, a certain file path can be / ...... / D / D2 / D22 / D221, and each file path in the to-be-scanned list can be scanned in turn in an order from top to bottom in the embodiment of the application. Alternatively, each file path in the to-be-scanned list can also be scanned in turn in an order from bottom to top in the embodiment of the application. Alternatively, each file path in the to-be-scanned list can also be scanned in a user-defined order in the embodiment of the application. This is only an exemplary illustration, and no limitation is made thereto.
[0249] In the process of scanning the file path, the listening scanning management module determines whether the file path has a corresponding scanning task after scanning each file path. If the file path does not have a corresponding scanning task, the next file path can be directly scanned, thereby reducing the scanning time and improving the file synchronization efficiency. If the file path has a corresponding scanning task, the scanning result corresponding to the file path is obtained, so as to facilitate subsequent feedback of the scanning result to the scanning task corresponding to the file path. If the file path has a corresponding scanning task, and the file path is any file path in the associated file path, the scanning result of any file path is obtained, so as to facilitate subsequent feedback of the scanning result to the scanning task corresponding to each file path in the associated file path.
[0250] Alternatively, in a possible implementation manner, all the scanning results scanned can be sent / notified to the REPO management module, thereby providing guarantee for subsequent implementation of file synchronization.
[0251] In this implementation manner, each file path in the to-be-scanned list is scanned, so that any scanning task is not missed, thereby guaranteeing that no file is missed in subsequent file synchronization.
[0252] S403, the scanning result is fed back to the scanning task corresponding to each file path in the associated file path.
[0253] Taking the associated file paths D and D1 as examples, when the listening and scanning management module scans the file path D, it is determined that the file path D has a corresponding scanning task, and the file path D is one of the associated file paths D and D1, and the scanning result corresponding to the file path D is obtained. The scanning result corresponding to the file path D is fed back / notified to the scanning task corresponding to the file path D and the scanning task corresponding to the file path D1.
[0254] In this implementation, when the associated file path is scanned, it can be ensured that each scanning task corresponding to the associated file path receives the scanning result notification, which facilitates subsequent synchronization of files scanned based on each scanning task to the trusted electronic device, and provides a guarantee for the accuracy of file synchronization while reducing the number of scans and reducing the power consumption of the electronic device.
[0255] Optionally, in a possible implementation, the method for processing data provided by the embodiment of the application can further include: adding the scanning result to a preset notification list.
[0256] Exemplarily, the notification list can be preset in the listening and scanning management module, and the notification list is used to feed back the scanning result to the scanning task corresponding to each file path in the associated file paths.
[0257] In the embodiment of the application, the scanning result can be obtained by calling a callback function. In order to save storage space and improve the efficiency of file synchronization, the scanning result is added to the preset notification list, and specifically, the callback corresponding to the scanning result is added to the preset notification list.
[0258] For example, the listening and scanning management module scans a file path, determines that the file path has a corresponding scanning task, and then finds the callback corresponding to the file path and adds the callback to the preset notification list.
[0259] For another example, the listening and scanning management module scans any file path in the associated file paths, obtains the callback of any file path, and adds the callback to the preset notification list. Adding the callback to the preset notification list can ensure that the scanning result is notified / fed back to the scanning task of the other file path associated with the file path.
[0260] Taking the file paths D and D1 as examples, the callback corresponding to the file path D is added to the preset notification list, and the scanning results of the file path D and the sub-file paths thereof are notified / feedback to the scanning task corresponding to the file path D and the scanning task corresponding to the file path D1. In this way, it is beneficial to subsequently synchronize the files scanned based on the scanning tasks to the trusted electronic device, and the accuracy of file synchronization is ensured while reducing the number of scans and reducing the power consumption of the electronic device.
[0261] Optionally, in a possible implementation manner, the method for processing data provided by the embodiment of the present application can further include: after scanning each file path in the to-be-scanned list, deleting all the scanning results in the notification list.
[0262] For example, the listening scanning management module periodically scans all the file paths in the to-be-scanned list, and after scanning the file paths in the to-be-scanned list once, deletes all the scanning results in the notification list, that is, deletes all the scanning result callbacks in the notification list. This one-time deletion of all the callbacks in the notification list simplifies the deletion step and improves the deletion efficiency.
[0263] Optionally, in a possible implementation manner, the method for processing data provided by the embodiment of the present application can further include: after scanning any file path in the associated file paths, deleting the scanning result corresponding to the file path in the notification list.
[0264] For example, the listening scanning management module scans any file path in the associated file paths, and deletes the callback corresponding to the file path from the notification list. This deletion of one callback after scanning one file path can save storage space, avoid false feedback, and improve the accuracy of file synchronization.
[0265] In each of the above embodiments, when scanning the file paths, first scanning can be performed, and then the next scanning start time (such as the second scanning start time) is set according to the scanning time interval. When the current time reaches the next scanning start time (such as the second scanning start time), the second scanning is started. When the second scanning is performed, the next scanning start time (such as the third scanning start time) is set according to the scanning time interval, and so on. In this way, the setting of the scanning start time can be reduced, the power consumption of the electronic device is reduced, and the system resources are saved.
[0266] Optionally, in one possible implementation, when scanning the file path, the scanning start time can be set first, and the scanning is started when the current time reaches the scanning start time. For example, the first scanning start time is set according to the scanning time interval, and the first round of scanning is started when the current time reaches the first scanning start time. When the first round of scanning is performed, the next scanning start time (such as the second scanning start time) is set according to the scanning time interval, and so on.
[0267] Exemplarily, the scanning start time of the target scanning task is set according to the target scanning time interval, and the scanning is started when the current time reaches the scanning start time. After the current round of scanning is completed, the listening scanning management module is triggered to set the next scanning start time to the timer. For example, the target scanning time interval is 2 hours, the time required for scanning a round of file paths of the target scanning task is 5 minutes, and the first scanning start time of the target scanning task is set to 1:55. When the current time reaches 1:55, the timer detects and triggers the listening scanning management module to start scanning. The listening scanning management module completes the current round of scanning for 5 minutes, sets the next scanning start time to 3:55 to the timer, and so on.
[0268] This way of setting the scanning start time first and then starting to scan the file path can accurately record the execution time of each scanning operation and avoid scanning errors. Determining the start and end time of each scanning operation is helpful for reasonably allocating system resources.
[0269] The setting of the timing scanning in the embodiments of the present application is described below with reference to the accompanying drawings. Please refer to Figure 12 , Figure 12 A flowchart of setting the timing scanning is shown in the embodiments of the present application. The method comprises:
[0270] S501, the REPO management module sends a setting timing scanning notification to the listening scanning management module.
[0271] Exemplarily, the REPO management module can be used to manage the REPO directory, obtain the parameters included in the setting timing scanning notification from the REPO directory, and send them to the listening scanning management module.
[0272] The setting timing scanning notification can include various file paths, the scanning time interval corresponding to each file path, the callback of the file path, and the like.
[0273] S502, the listening scanning management module performs parameter verification.
[0274] Exemplarily, the monitoring and scanning management module checks the parameters of each file path, the scanning time interval corresponding to each file path, the callback of the file path, and the like, to ensure that these parameters are valid. For example, the monitoring and scanning management module checks whether the types of these parameters are consistent with expectations, whether the formats are correct, whether they are consistent with the data in the local file system, whether the scanning results corresponding to the file path can be accurately obtained through the callback, whether the scanning time interval is the scanning time interval of the scanning task corresponding to the file path, and the like.
[0275] S503. The monitoring and scanning management module determines the inclusion relationship between the plurality of file paths.
[0276] The monitoring and scanning management module can determine the inclusion relationship between the plurality of file paths in the manner described in step S303.
[0277] S504. The monitoring and scanning management module sets a timing scan for the timer.
[0278] For each file path of the associated scanning task, if there is no inclusion relationship between the file path and other file paths, the scanning start time corresponding to the file path is determined according to the scanning time interval corresponding to the file path, and the scanning time interval and the scanning start time are sent to the timer. When the timer detects that the current time reaches the scanning start time, the monitoring and scanning management module is notified to scan the file path.
[0279] S505. The monitoring and scanning management module sets a timing scan for the timer according to the target scanning time interval.
[0280] For each file path of the associated scanning task, if there is an inclusion relationship between the file path and other file paths, the scanning tasks corresponding to the file paths with the inclusion relationship are merged to obtain a target scanning task. The scanning start time corresponding to the target scanning task is determined according to the target scanning time interval, and the target scanning time interval and the scanning start time are sent to the timer. The target scanning time interval can be the smallest scanning time interval among the plurality of scanning time intervals corresponding to the file paths with the inclusion relationship.
[0281] S506. The monitoring and scanning management module returns a setting result to the REPO management module.
[0282] The setting result can include a setting success or a setting failure. For example, when an application, a system, or the like is abnormal, a setting failure can occur. The monitoring and scanning management module returns the setting result to the REPO management module according to the actual setting situation, and the REPO management module can record the setting result in the REPO directory.
[0283] In this implementation, different scan start times and scan time intervals are set for different file paths of association scan tasks, which helps to reasonably allocate system resources and provides guarantee for reducing the number of scans and reducing the power consumption of the electronic device in the subsequent scan process.
[0284] The scene of setting the timing scan in the embodiments of the present application is described above in combination with the drawings. The scene of timing scan file paths in the embodiments of the present application is described below in combination with the drawings. Please refer to Figure 13 , Figure 13 A flowchart of timing scan file paths is shown for the embodiments of the present application. The method comprises:
[0285] S601, the timer informs the listening scan management module to start scanning.
[0286] The timer continuously monitors the time, and when it monitors that the current time reaches the scan start time, it informs the listening scan management module to start scanning.
[0287] Optionally, the timer can carry the to-be-scanned list when it informs the listening scan management module to start scanning.
[0288] S602, the listening scan management module determines whether the file path is associated with a scan task.
[0289] In one example, the listening scan management module can traverse all file paths in the to-be-scanned list, and determine whether each file path is associated with a scan task.
[0290] S603, the listening scan management module adds the callback function to the preset notification list.
[0291] Illustratively, when the listening scan management module determines that a certain file path is associated with a scan task, it finds the callback corresponding to the file path and adds the callback to the preset notification list.
[0292] S604, the listening scan management module informs the REPO management module to start scanning and starts scanning the file path.
[0293] S605, the listening scan management module obtains the scan result from the file system.
[0294] S606, the listening scan management module notifies according to the notification list.
[0295] The listening scan management module feeds back the scan result to each scan task corresponding to the file path in the associated file path according to the notification list.
[0296] Optionally, the listening scan management module can send the notification result to the REPO management module.
[0297] S607, the listening scan management module notifies the REPO management module of the end of scanning.
[0298] S608, the listening scan management module deletes the callback function in the notification list.
[0299] S609, the listening scan management module sets the next scanning start time for the timer.
[0300] For details of steps S601 to S609, please refer to the relevant description in the foregoing embodiments, which will not be repeated here.
[0301] The following describes a scenario of canceling a scanning task in the embodiments of the present application in combination with the accompanying drawings. Please refer to Figure 14 , Figure 14 A flowchart of canceling a scanning task is shown in the embodiments of the present application. The method comprises:
[0302] S701, a cancel scanning notification is obtained.
[0303] The cancel scanning notification is used to cancel any scanning task corresponding to the associated file path.
[0304] It should be understood that the cancel scanning notification is similar to the file synchronization request, which can be triggered by an electronic device or a trusted electronic device. Illustratively, the electronic device or the trusted electronic device will trigger the cancel scanning notification when receiving the user's operation of closing the file synchronization function, canceling a previously synchronized file, changing the scanning time interval, etc. For example, the picture is originally set to be automatically synchronized every 6 hours, and now it is modified to be automatically synchronized every 3 hours; for another example, the picture and music in the mobile phone are originally set to be synchronized to the tablet computer, and now it is set to only synchronize the music in the mobile phone to the tablet computer, etc.
[0305] S702, the scanning start time of the target scanning task is cleared.
[0306] In one example, when the cancel notification is used to cancel the scanning task corresponding to the non-associated file path of the associated scanning task, the timer setting related to the non-associated file path is deleted. For example, the file path of the file directory A is a non-associated file path of the associated scanning task, and when the cancel notification is used to cancel the scanning task corresponding to the file directory A, the scanning start time corresponding to the file directory A in the timer is cleared.
[0307] Optionally, all information related to the non-associated file path can also be cleared by the listening scanning management module, and the listening scanning management module no longer listens to and scans the non-associated file path. For example, information related to the non-associated file path in the REPO directory is deleted.
[0308] In another example, when the cancel notification is used to cancel any scanning task corresponding to the associated file path, the scanning start time of the target scanning task in the timer is cleared.
[0309] In this implementation, when the cancel scanning notification is obtained, the related information of the scanning task is cleared, which can release more system resources, reduce the system processing burden, and improve the system processing speed. At the same time, the different needs of the user in the file synchronization scene are responded in time, and the user experience is improved.
[0310] Optionally, in a possible implementation, the method for processing data provided by the embodiment of the present application can include steps S7021 and S7022, specifically as follows.
[0311] S7021, determine that there is no containing relationship between the other multiple file paths.
[0312] S7022, clear the scanning start time of the target scanning task.
[0313] The other multiple file paths are multiple file paths other than the file path corresponding to any scanning task.
[0314] For example, when the cancel notification is used to cancel any scanning task corresponding to the associated file path, it is determined whether there is a containing relationship between the other multiple file paths. If the other multiple file paths are traversed by means of a graph structure, a graph algorithm, a tree, a graph database, a function, etc., it is determined that there is no containing relationship between the other multiple file paths, and the scanning start time of the target scanning task is cleared.
[0315] In this implementation, when it is determined that there is no containing relationship between the other multiple file paths, the related information of the scanning task is cleared, which avoids affecting other scanning tasks when the related information of the scanning task is cleared, and ensures that other scanning tasks can be completed smoothly.
[0316] Optionally, in a possible implementation, the method for canceling a scanning task provided by the present application can further include, after the cancel scanning notification is obtained: determining that there is a containing relationship between the other multiple file paths, and merging the scanning tasks corresponding to the other multiple file paths with the containing relationship.
[0317] Exemplarily, if it is determined that there is a containing relationship between the other multiple file paths by means of graph structure, graph algorithm, tree, graph database, writing functions, etc., the scanning time intervals corresponding to the file paths with the containing relationship are obtained, the scanning tasks corresponding to the file paths with the containing relationship are merged into a new target scanning task, and the new scanning time interval corresponding to the new target scanning task is set according to the scanning time intervals corresponding to the file paths with the containing relationship. For specific methods, reference can be made to the description in the above step S304, which will not be described here again.
[0318] In combination Figure 9 In an implementation scenario, it is assumed that the scanning tasks corresponding to the file directories D, D1, D2 and D221 have all been started, where the file path corresponding to the file directory D is / ...... / D, the scanning time interval is 1 day; the file path corresponding to the file directory D1 is / ...... / D / D1, the scanning time interval is 3 days; the file path corresponding to the file directory D2 is / ...... / D / D2, the scanning time interval is 2 hours; and the file path corresponding to the file directory D221 is / ...... / D / D2 / D22 / D221, the scanning time interval is 6 hours.
[0319] D, D1, D2 and D221 represent the scanning tasks corresponding to the file directories D, D1, D2 and D221 respectively. The cancellation scanning notification is obtained, which is used to cancel the scanning task D, and the remaining scanning tasks are D1, D2 and D221. The file path corresponding to the scanning task D1 is not associated with the file paths corresponding to the other tasks, and the scanning time interval corresponding to the scanning task D1 is set to 3 days. There is a containing relationship between the file paths corresponding to the scanning tasks D2 and D221, the scanning time interval corresponding to the scanning task D2 is less than the scanning time interval corresponding to the scanning task D221, and the scanning time intervals corresponding to the scanning tasks D2 and D221 are updated to 2 hours.
[0320] Optionally, the scanning tasks D2 and D221 can also be merged into a target scanning task D221, and the scanning time interval corresponding to the target scanning task D221 is set to 2 hours.
[0321] Optionally, if the listening scanning management module is currently scanning the file path corresponding to the file directory D3, the notification of the scanning result has no effect. If the listening scanning management module is currently scanning the file paths corresponding to the file directories D1 or D2, the scanning result only notifies the scanning task corresponding to the file directory D1 or the scanning task corresponding to the file directory D2, and no longer notifies the scanning task corresponding to the file directory D.
[0322] Optionally, if the listening scanning management module is currently scanning the file path corresponding to the file directory D3, the notification of the scanning result has no effect. If the listening scanning management module is currently scanning the file paths corresponding to the file directories D1 or D2, the scanning result only notifies the scanning task corresponding to the file directory D1 or the scanning task corresponding to the file directory D2, and no longer notifies the scanning task corresponding to the file directory D.
[0323] In another implementation scenario, the cancel scanning notification is obtained, the cancel scanning notification is used to cancel the scanning task D2, and the remaining scanning tasks are D, D1 and D221. The scanning tasks D, D1 and D221 correspond to file paths that have a containing relationship, and the minimum scanning time interval therebetween is 6 hours, and the scanning time interval corresponding to the scanning tasks D, D1 and D221 is updated to 6 hours.
[0324] Optionally, the scanning tasks D and D1 can also be merged into a target scanning task D1, the scanning time interval corresponding to the target scanning task D1 is updated to 6 hours, and the scanning tasks D and D221 can also be merged into a target scanning task D221, and the scanning time interval corresponding to the target scanning task D221 is updated to 6 hours.
[0325] Optionally, if the listening scanning management module is currently scanning the file path corresponding to the file directory D21, the scanning result only notifies the scanning task corresponding to the file directory D; if the listening scanning management module is currently scanning the file path corresponding to the file directory D11, the scanning result notifies the scanning tasks corresponding to the file directories D and D1 respectively; and if the listening scanning management module is currently scanning the file path corresponding to the file directory D221, the scanning result only notifies the scanning tasks corresponding to the file directories D and D221, and does not notify the scanning task corresponding to the file directory D2.
[0326] In this implementation, after the cancel scanning notification is obtained, the scanning tasks corresponding to the file paths that have a containing relationship are merged, so that when the merged scanning task is executed, multiple scanning of the same file path can be avoided, thereby effectively reducing the scanning times, reducing the workload of repeated scanning, reducing the power consumption of the electronic device, optimizing the resource allocation in the system, speeding up the entire file synchronization process, and improving the subsequent file synchronization efficiency.
[0327] Please refer to Figure 15 , Figure 15 Another flowchart for canceling a scanning task is shown in the embodiments of the present application. The method comprises:
[0328] S801, the REPO management module sends a cancel timing scanning notification to the listening scanning management module.
[0329] Exemplarily, the REPO management module can be used to manage the REPO directory, obtain the cancel timing scanning notification from the REPO directory, and send it to the listening scanning management module.
[0330] The cancel timing scanning notification is used to cancel any scanning task, and the cancel timing scanning notification can include the file path corresponding to any scanning task to be canceled, the scanning time interval corresponding to the file path, the callback of the file path, and the like.
[0331] S802, the scanning management module performs parameter verification.
[0332] For the description of step S802, please refer to the specific implementation process in the aforementioned step S502, which will not be repeated here.
[0333] S803, the scanning management module determines the inclusion relationship between the other multiple file paths.
[0334] The scanning management module can determine the inclusion relationship between the multiple file paths in the manner described in the aforementioned step S303.
[0335] When the file path of the canceled scanning task does not have an inclusion relationship with the other multiple file paths, steps S804 to S805 are executed; when the file path of the canceled scanning task has an inclusion relationship with the other multiple file paths, steps S806 to S812 are executed.
[0336] S804, the scanning management module deletes the timing setting of the file path of the canceled scanning task.
[0337] It is worth noting that the canceled scanning task is only a different expression from the aforementioned canceled scanning task, and refers to the same content.
[0338] Exemplarily, the timing setting refers to the scanning time interval and the scanning start time related to the canceled scanning task before it is canceled. The scanning management module sends a command to delete the timing setting to the timer, and the timer deletes the timing setting related to the file path of the canceled scanning task. After that, the timer no longer monitors the time related to the canceled scanning task, and the scanning management module no longer monitors and scans the file path of the canceled scanning task.
[0339] S805, the scanning management module clears the related information of the file path of the canceled scanning task.
[0340] The related information of the file path of the canceled scanning task can include the scanning start time, the scanning time interval, the file synchronization configuration information, the callback function of the file path, and other information related to the file path in the REPO directory.
[0341] Exemplarily, the information related to the file path of the canceled scanning task in the REPO directory is deleted.
[0342] When the file path of the canceled scanning task is contained in the plurality of file paths, steps S806-S808 are performed; when the file path of the canceled scanning task is contained in the plurality of file paths, steps S809-S811 are performed.
[0343] S806, the monitoring scanning management module determines the minimum scanning time interval corresponding to the plurality of file paths.
[0344] For example, when the file path of the canceled scanning task is contained in any of the plurality of file paths, the monitoring scanning management module acquires the scanning time intervals corresponding to the plurality of file paths respectively, and determines the minimum scanning time interval from the scanning time intervals corresponding to the plurality of file paths respectively.
[0345] S807, the monitoring scanning management module sets the scanning start time corresponding to the plurality of file paths.
[0346] The monitoring scanning management module determines the minimum scanning time interval as the minimum scanning time interval corresponding to the plurality of file paths respectively, and determines the scanning start time corresponding to the plurality of file paths respectively according to the minimum scanning time interval. Then, the monitoring scanning management module sends the scanning start time corresponding to the plurality of file paths respectively and the minimum scanning time interval to the timer.
[0347] S808, if it is detected that scanning is in progress, update the scanning list.
[0348] For example, scanning in progress means that a scanning task is being executed. If a scanning task is being executed when the cancel timing scanning notification is acquired, for example, a file path is being monitored and scanned, the file path of the canceled scanning task is deleted from the scanning list.
[0349] S809, if it is detected that scanning is in progress, remove the file path unrelated to the file path of the canceled scanning task from the scanning list.
[0350] For example, the file path unrelated to the file path of the canceled scanning task in the scanning list is determined. If a scanning task is being executed when the cancel timing scanning notification is acquired, for example, a file path is being monitored and scanned, the file path unrelated to the file path of the canceled scanning task in the scanning list is removed / deleted.
[0351] It should be understood that the monitoring scanning management module will still monitor, scan, and feed back the scanning result for the file path associated with the file path of the canceled scanning task.
[0352] S810, determine a scanning list after deleting the file path of the canceled scanning task, and scanning time intervals corresponding to the other plurality of file paths.
[0353] S811, listen to the timing setting of the scanning management module deleting the file path of the canceled scanning task.
[0354] S812, set the next scanning start time of the other plurality of file paths.
[0355] S813, listen to the scanning management module returning the setting result to the REPO management module.
[0356] For the specific implementation of steps S810 to S813, please refer to the relevant description in the foregoing embodiments, which will not be repeated here.
[0357] It is worth noting that the method for processing data provided by the present application can be applied to any scenario that needs to monitor and scan files. When synchronizing files between electronic devices in a trust circle, the method for processing data can be applied in the electronic devices or in the trusted electronic devices.
[0358] In the related art, when synchronizing files between electronic devices in a trust circle, the synchronized files are not checked, which may result in inconsistency between the synchronized files and the source files, affecting the integrity of file synchronization. If the synchronized files are tampered with, it will also pose a security risk to the electronic devices in the trust circle, resulting in an unsafe and error-prone entire file synchronization process.
[0359] Therefore, the embodiments of the present application further provide a file synchronization method applied to an electronic device, wherein a trust circle in which the electronic device is located further includes at least one trusted electronic device, and the method includes: obtaining a to-be-synchronized file sent by the at least one trusted electronic device; generating a temporary synchronization file according to the to-be-synchronized file; checking the temporary synchronization file; and when the temporary synchronization file passes the check, synchronizing the temporary synchronization file to a file system. Optionally, checking the temporary synchronization file can include checking the integrity of the temporary synchronization file, the consistency between the temporary synchronization file and the source file, whether the function of the temporary synchronization file is normal, and the like.
[0360] In this implementation, since the temporary synchronization file is checked, it can be ensured that the file received by the electronic device is consistent with the source file, ensuring the integrity of file synchronization and improving the accuracy of file synchronization. Checking the temporary synchronization file can also ensure that the synchronized file is not tampered with, avoiding the system of the electronic devices in the trust circle from being attacked by malicious software or viruses, and improving the security of the file synchronization process.
[0361] Optionally, the verifying the temporary synchronization file comprises: obtaining source end metadata sent by the 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 verification when it is detected that the verification value of the temporary synchronization file is consistent with the verification value of the source end metadata. Optionally, the verification value of the temporary synchronization file and the verification value of the source end metadata can each comprise a weak hash value, a strong hash value, a checksum, a hash-based message authentication code, or the like. In this implementation, the consistency of the temporary synchronization file and the source file is verified, and the files are synchronized only when the temporary synchronization file and the source file are consistent, which can ensure that the final synchronized files are accurate and improve the accuracy of file synchronization. Verifying the temporary synchronization file can also ensure that the synchronized files are not tampered with and the synchronization process is less likely to fail, effectively avoiding attacks on the system of the electronic device in the trust ring by malicious software or viruses, and improving the security of the file synchronization process.
[0362] Optionally, the synchronizing the temporary synchronization file to the file system comprises: deleting a local file corresponding to the temporary synchronization file in the file system; modifying the file name of the temporary synchronization file; and storing the temporary synchronization file with the modified 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 this implementation, the local file is deleted first, and then the file name of the temporary synchronization file is modified, which can avoid file name conflicts and reduce errors caused by inconsistent file names or file versions, and help ensure the integrity and consistency of file synchronization.
[0363] Optionally, the generating the temporary synchronization file according to the file to be synchronized comprises: performing incremental synchronization on the local file and the file to be synchronized to generate the temporary synchronization file. In this implementation, the multi-end synchronization of the file is completed using the incremental synchronization method, which can effectively reduce the amount of data transmitted and save bandwidth. Moreover, because the amount of data transmitted is reduced, the file synchronization process is accelerated, and the overall data synchronization efficiency is improved. At the same time, because the electronic device only needs to process the files that have changed, the load in the file synchronization process is effectively reduced, and the power consumption of the electronic device is reduced.
[0364] Optionally, before the file synchronization method obtains the file to be synchronized sent by the at least one trusted electronic device, it can further comprise: obtaining local metadata; detecting whether the local metadata matches the local file; comparing whether the local metadata and the source end metadata are consistent when it is detected that the local metadata matches the local file; and updating the local file when the local metadata and the source end metadata are consistent. In this implementation, the local metadata and the local file, and the local metadata and the source end metadata are verified, and the subsequent file synchronization process is performed only when both verifications pass, which can ensure the accuracy of the subsequent file synchronization result.
[0365] Optionally, the file synchronization method can further include, after detecting that the local metadata matches the local file and comparing the local metadata with the source metadata, determining difference data between the local metadata and the source metadata when the local metadata and the source metadata are inconsistent.
[0366] 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. In this implementation, when it is determined that the local file and the source file are inconsistent, the difference data is sent to the trusted electronic device to trigger the trusted electronic device to send the file to be synchronized to the electronic device, thereby providing a guarantee for file synchronization.
[0367] Optionally, the file synchronization method can further include, after determining the difference data between the local metadata and the source metadata when the local metadata and the source metadata are inconsistent, sending the source metadata and the difference data to the at least one trusted electronic device. The source metadata is sent to check whether the source metadata matches a local file in the at least one trusted electronic device, and the difference data is sent 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. In this implementation, the source file and the metadata of the trusted electronic device are checked first, and the subsequent file synchronization process is performed only when the source file is correct, thereby ensuring the accuracy of the subsequent file synchronization result.
[0368] In related technologies, when electronic devices in a trust circle perform file synchronization, if at least two different directories in the electronic devices need to synchronize the same file from a trusted electronic device, or the same file in the source device (i.e., the trusted electronic device) needs to be synchronized to different directories in the electronic devices, the trusted electronic device usually sends the same file to the electronic devices at least twice, i.e., the trusted electronic device sends the same file to different directories in the electronic devices. However, in the file synchronization process, the file needs to be checked each time the file is sent across devices, and the trusted electronic device sends the same file to the electronic devices multiple times, which means that the same file needs to be checked multiple times, resulting in a complex and tedious file transmission process. Repeated transmission of the same file increases the use of network bandwidth and processing time, which not only affects other file synchronization but also reduces the efficiency of file synchronization. Moreover, repeated transmission multiple times also increases the power consumption of the electronic devices and the trusted electronic device, increases the risk of data leakage, and reduces the security of file synchronization.
[0369] Therefore, the embodiment of the present application further provides a file synchronization method applied to an electronic device, wherein a trust circle in which the electronic device is located further comprises at least one trusted electronic device, and the method comprises the following steps: determining that at least two directories in the electronic device synchronize a same file from the at least one trusted electronic device; any directory requesting to obtain the same file from the at least one trusted electronic device; any directory being any one of the at least two directories; and any directory sending the obtained same file to other directories, the other directories being the directories other than the any directory among the at least two directories.
[0370] 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 only transmitted across devices once for the electronic device and the trusted electronic device, and the whole file transmission process is simple and convenient. Since the number of file transmissions is small, the use of network bandwidth and processing time is reduced, the power consumption of the electronic device and the trusted electronic device is reduced, and the efficiency of file synchronization is improved. Reducing the number of file transmissions can also reduce the risk of data leakage and improve the security of file synchronization.
[0371] Moreover, any directory in the electronic device sends the same file to other directories in the electronic device, and since the file is transmitted in the same electronic device, the transmission speed is fast and the risk is low, the efficiency and security of file synchronization are improved. In the transmission process, no additional network bandwidth is consumed, the transmission cost is reduced, the transmission is not easily affected by network fluctuations or external interference, and the reliability of the transmission is improved. Moreover, file operations are performed in the same electronic device, and the operating system and file system of the electronic device can better maintain the properties and permissions of the file to ensure the integrity of the file.
[0372] Optionally, the step of determining that the at least two directories synchronize the same file from the at least one trusted electronic device comprises the following steps: obtaining a list of files to be synchronized; comparing the files to be synchronized corresponding to the at least two directories respectively; and when the files to be synchronized corresponding to the at least two directories respectively are consistent, determining that the at least two directories synchronize the same file from the at least one trusted electronic device. In this implementation, the files to be synchronized corresponding to the at least two directories are verified to ensure that the at least two directories indeed synchronize the same file from the trusted electronic device, so that the files finally synchronized to each directory are accurate and correct, and the accuracy of file synchronization is improved.
[0373] Optionally, the comparison of the to-be-synchronized files corresponding to the at least two directories respectively comprises: obtaining metadata of the to-be-synchronized files corresponding to the at least two directories; and when the metadata of the to-be-synchronized files corresponding to the at least two directories are consistent, determining that the at least two directories are both synchronized with the same file from the at least one trusted electronic device. In this implementation, the metadata of the to-be-synchronized files corresponding to the at least two directories are checked to ensure that the at least two directories are indeed synchronized with the same file from the trusted electronic device, so that the files finally synchronized into each directory are accurate, and the accuracy of file synchronization is improved.
[0374] Optionally, the request of any directory for the same file from the at least one trusted electronic device comprises: initiating, by any directory, a file synchronization request to the at least one trusted electronic device, where the file synchronization request is used to trigger the at least one trusted electronic device to send the same file to the electronic device; and marking other directories as synchronized with the same file by any directory. In this implementation, after any directory initiates the file synchronization request to the at least one trusted electronic device, other directories are marked, so that any directory can quickly and accurately send the same file to the marked other directories after obtaining the same file, and the files finally synchronized into each directory are accurate, and the accuracy of file synchronization is improved.
[0375] Optionally, the sending of the same file obtained by any directory to other directories comprises: obtaining a file path of the marked other directories; and copying the same file into the file path of the marked other directories. In this implementation, after any directory in the electronic device obtains the same file to be synchronized, the same file is copied into the file path of other directories according to the file path of the marked other directories. Since the file is transmitted in the same electronic device, the transmission speed is high and the risk is low, the efficiency and safety of file synchronization are improved. In the transmission process, no additional network bandwidth is consumed, the transmission cost is reduced, the transmission is not easily affected by network fluctuations or external interference, and the reliability of transmission is improved. In addition, the file operation is performed in the same electronic device, and the operating system and file system of the electronic device can better maintain the attributes and permissions of the file, and ensure the integrity of the file.
[0376] Optionally, the trust circle in which the electronic device is located further comprises at least two trusted electronic devices, and the same synchronization file is stored in each of the at least two trusted electronic devices. The file synchronization method can further comprise: obtaining an influence factor of each trusted electronic device; determining a synchronization source device from the at least two trusted electronic devices according to the influence factor of each trusted electronic device; and synchronizing the synchronization file from the synchronization source device. The influence factor is used to influence the determination of the synchronization source device, that is, the influence factor is a factor used to influence the determination of which trusted electronic device is the synchronization source device. The synchronization source device is different, and the file synchronization effect is different, that is, the influence factor can be used to influence the file synchronization effect between the electronic device and the trusted electronic device. The influence factor comprises 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.
[0377] In this implementation, the influence factor of each trusted electronic device is considered, so that the most suitable synchronization source device can be selected from the plurality of trusted electronic devices, the synchronization operation can be ensured to be more efficient, and the consistency and accuracy of the synchronized files can be maintained. At the same time, the overload situation can be avoided, the device resources can be reasonably allocated and optimally used, unnecessary resource consumption can be reduced, the file synchronization cost can be reduced, and the reliability of file synchronization can be enhanced.
[0378] Optionally, the determination of the synchronization source device from the at least two trusted electronic devices according to the influence factor of each trusted electronic device comprises: calculating a synchronization suitability score for each trusted electronic device according to the influence factor of each trusted electronic device; and determining the synchronization source device from the at least two trusted electronic devices according to the synchronization suitability score of each trusted electronic device. In this implementation, the synchronization suitability score of the trusted electronic device is calculated, and the synchronization source device is determined according to the synchronization suitability score to perform file synchronization. The most suitable synchronization source device can be selected from the plurality of trusted electronic devices, the synchronization operation can be ensured to be more efficient, and the consistency and accuracy of the synchronized files can be maintained. At the same time, the overload situation can be avoided, the device resources can be reasonably allocated and optimally used, unnecessary resource consumption can be reduced, the file synchronization cost can be reduced, and the reliability of file synchronization can be enhanced.
[0379] Optionally, the device types of the at least two trusted electronic devices are different, and the determining of the synchronization source device from the at least two trusted electronic devices according to the influence factors of each trusted electronic device comprises: determining a priority of each trusted electronic device according to the influence factors of each trusted electronic device; and determining the synchronization source device from the at least two trusted electronic devices according to the priority of each trusted electronic device. In this implementation, the synchronization source device is determined by determining the priority of the device, which can reasonably allocate resources according to the importance and functions of different devices, and select a suitable synchronization source device, thereby improving the efficiency and accuracy of subsequent file synchronization.
[0380] The method for processing data provided by the embodiments of the present application is described above in combination with the flowchart, and the hardware structure of the electronic device involved in the embodiments of the present application is briefly introduced below in combination with the drawings.
[0381] In some embodiments of the present application, the electronic device can be a mobile phone, a tablet computer, a wearable device, a television, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., or can be other devices or apparatuses capable of scene recognition, and the embodiments of the present application do not make any limitation on the specific type of the electronic device.
[0382] For reference Figure 16 , Figure 16 The hardware structure of the electronic device shown in the embodiments of the present application is shown in the following figure.
[0383] As Figure 16As shown, the electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging 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, a headphone jack 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0384] It can be understood that the structures shown in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than those shown, or the electronic device 100 can include a combination of some of the components shown, or the electronic device 100 can include sub-components of some of the components shown. Figure 16 It can be understood that the structures shown in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than those shown, or the electronic device 100 can include a combination of some of the components shown, or the electronic device 100 can include sub-components of some of the components shown. Figure 16 It can be understood that the structures shown in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than those shown, or the electronic device 100 can include a combination of some of the components shown, or the electronic device 100 can include sub-components of some of the components shown. Figure 16 It can be understood that the structures shown in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than those shown, or the electronic device 100 can include a combination of some of the components shown, or the electronic device 100 can include sub-components of some of the components shown. Figure 16 The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0385] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc.
[0386] It can be understood that the interface connection relationship between the modules shown in the embodiments is only illustrative and does not constitute a structural limitation on the electronic device 100. In other embodiments, the electronic device 100 can also use different interface connection modes or a combination of multiple interface connection modes.
[0387] The electronic device 100 can implement the display function through the GPU, the display screen 194, and the application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU can also be used to perform mathematical and pose calculations for graphics rendering, etc. The processor 110 can include one or more GPUs, and execution of program instructions by the GPU can generate or change display information.
[0388] The display screen 194 can be used to display images or videos, and can also display a series of graphical user interfaces (GUIs), which are all home screens of the electronic device 100. Generally, the size of the display screen 194 of the electronic device 100 is fixed, and only limited controls can be displayed in the display screen 194 of the electronic device 100. A control is a GUI element, which is a software component included in an application program, controls all data processed by the application program and interaction operations related to the data, and a user can interact with the control through direct manipulation to read or edit relevant information of the application program. Generally, a control can include an icon, a button, a menu, a tab, a text box, a dialog box, a status bar, a navigation bar, a widget, and other visual interface elements.
[0389] The display screen 194 in the embodiments of the present application can be a touch screen. The display screen 194 can be integrated with a touch sensor 180K. The touch sensor 180K can also be referred to as a "touch panel". That is, the display screen 194 can include a display panel and a touch panel, and the touch sensor 180K and the display screen 194 form a touch screen, also referred to as a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. After the touch operation detected by the touch sensor 180K, the kernel layer driver (such as the TP driver) can pass it to the upper layer to determine the touch event type. The display screen 194 can provide visual output related to the touch operation. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0390] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to extend the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external memory card.
[0391] The internal memory 121 can be used to store computer executable program code, which includes instructions. The processor 110 executes various function applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one APP (such as a sound playing function, an image playing function, etc.) required by a function, and the like. The data storage area can store data (such as audio data, a phonebook, etc.) created during use of the electronic device 100, and the like.
[0392] In addition, the internal memory 121 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a Universal Flash Storage (UFS), and the like.
[0393] The keys 190 include a power-on key, a volume key, and the like. The keys 190 can be mechanical keys. Alternatively, the keys 190 can be touch keys. The electronic device 100 can receive a key input and generate a key signal input related to user settings and function control of the electronic device 100.
[0394] The motor 191 can generate a vibration prompt. The motor 191 can be used for incoming call vibration prompts and also for touch vibration feedback.
[0395] The method for processing data and the file synchronization method provided in the embodiments of the present application can be implemented in the electronic device 100 having the hardware structure described above.
[0396] The method for processing data provided in the present application is described below in combination with a software structure. Please refer to Figure 17 , Figure 17 The software structure of the electronic device shown in the embodiments of the present application is shown in the following figure.
[0397] By way of example, a layered architecture divides software into several layers, each of which has a clear role and division of labor. Layers communicate with each other through software interfaces. In the embodiments of the present application, the electronic device is taken as an example of an Android system, and the Android system is divided into an Application (App) layer, a Framework layer, and a hardware abstraction layer.
[0398] The application program layer can include a series of application packages, such as a trust circle application. In the embodiments of the present application, a file synchronization SDK is integrated in the trust circle application, so that the trust circle application is configured with the capability of file synchronization.
[0399] Optionally, the application program layer can also include a database. The database provides the application program with functions of data storage, data modification, data deletion, data addition, data query, and the like.
[0400] The application program framework layer provides the application program of the application program layer with an application programming interface (API) and a programming framework. The application program framework layer includes some pre-defined functions.
[0401] Optionally, the hardware abstraction layer can include a file system.
[0402] As an example of the present application, the application program framework layer includes a file synchronization service module, which can include a REPO management module, a listening scanning management module, and a timer. The REPO management module can include a REPO directory, and the REPO management module can be used to manage the REPO directory.
[0403] Optionally, the application program framework layer can also include a database.
[0404] Optionally, the database can also interact with the hardware abstraction layer, such as calling and managing data in the file system through the operating system.
[0405] The trust circle application, the file synchronization service module, the database, and the file system interact with each other to implement the method of processing data and the file synchronization method in the above-mentioned method embodiments. For details, reference can be made to the related description in the foregoing embodiments, which will not be described here.
[0406] The above describes an example of the method of processing data provided by the embodiments of the present application in detail. It can be understood that the electronic device includes hardware and / or software modules corresponding to each function to implement the above-mentioned functions. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of the examples described in the embodiments disclosed in the present application, the present application can be realized in the form of hardware or a combination of hardware and computer software. Whether a certain function is driven by hardware or computer software, it depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered beyond the scope of the present application.
[0407] The embodiments of the present application can divide the function modules of the electronic device according to the above method examples. For example, each function module can be divided according to each function, or two or more functions can be integrated into one module. The integrated module can be implemented in the form of hardware or in the form of a software function module. It should be noted that the division of the modules in the embodiments of the present application is illustrative, and is only a logical function division. In actual implementation, another division method can be used.
[0408] It should be noted that all related contents of each step involved in the above method embodiments can be cited in the function description of the corresponding function module, and will not be repeated here.
[0409] The electronic device provided in the embodiments can be used to execute the above data processing method, and thus the same effects as the above implementation method can be achieved.
[0410] In the case of using an integrated unit, the electronic device can further include a processing module, a storage module and a communication module. The processing module can be used to control and manage the actions of the electronic device. The storage module can be used to support the electronic device to execute program codes and data, etc. The communication module can be used to support the communication between the electronic device and other devices.
[0411] The processing module can be a processor or a controller. It can implement or execute various exemplary logical blocks, modules and circuits described in combination with the disclosure of the present application. The processor can also be a combination of computing functions, such as one or more microprocessor combinations, a combination of digital signal processing (DSP) and microprocessor, etc. The storage module can be a memory. The communication module can be a device for interacting with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, a WiFi chip, etc.
[0412] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor executes the data processing method of any one of the above embodiments.
[0413] The embodiments of the present application further provide a device, which can be a chip, a component or a module. The device can include a processor and a memory connected to each other. The memory is used to store computer execution instructions. When the device is running, the processor can execute the computer execution instructions stored in the memory, so that the chip executes the data processing method and the file synchronization method in the above method embodiments.
[0414] The embodiment of the present application further provides a computer program product, which, when running on a computer, causes the computer to execute the related steps to realize the data processing method in the above embodiment.
[0415] The embodiment of the present application further provides a chip. Figure 18 , Figure 18 Fig. 1 shows a structural schematic diagram of a chip according to an embodiment of the present application. Figure 18 The chip shown in Fig. 1 can be a general processor or a special processor. The chip includes a processor 210. The processor 210 is configured to execute the data processing method and the file synchronization method in any of the above embodiments.
[0416] Optionally, the chip further includes a transceiver 220, which is configured to be controlled by the processor and support the communication device to execute the technical solutions shown above.
[0417] Optionally, Figure 18 The chip shown in Fig. 1 can further include a storage medium 230.
[0418] It should be noted that, Figure 18 The chip shown in Fig. 1 can be implemented by using one or more field programmable gate arrays (FPGA), programmable logic devices (PLD), controllers, state machines, gate logic, discrete hardware components, any other suitable circuits, or any combination of circuits capable of performing the various functions described throughout this application.
[0419] The electronic device, the computer readable storage medium, the computer program product or the chip provided by the embodiment are all used to execute the corresponding method provided above, and thus the beneficial effects that can be achieved are referable to the beneficial effects in the corresponding method provided above, which will not be described herein again.
[0420] Through the description of the above embodiments, those skilled in the art can understand that, for the convenience and brevity, only the division of the above functional modules is taken as an example for illustration, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
[0421] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other manners. For example, the apparatus embodiments described above are merely illustrative, for example, the division of the modules or units is merely a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another apparatus, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some interfaces, apparatuses or units, and can be electrical, mechanical or other forms.
[0422] The units described as separate components can or can not be physically separate, and the components shown as units can be one physical unit or multiple physical units, that is, can be located in one place or can be distributed to multiple different places. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0423] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0424] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application essentially or the parts that make contributions to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing an apparatus (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the method of the embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various storage medium that can store program codes.
[0425] The above is merely a specific implementation of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method of processing data, characterized by, The method is applied to an electronic device, a trust circle in which the electronic device is located further comprises at least one trusted electronic device, and files in the electronic device can be synchronized to the at least one trusted electronic device, and the method comprises the following steps: A shared directory is created by calling a file synchronization SDK; the shared directory comprises a plurality of file paths, a scanning time interval and a file synchronization version; A file synchronization request is obtained; A plurality of scanning tasks corresponding to the file synchronization request are determined, and each scanning task corresponds to a file path; An associated file path is determined in the plurality of file paths, the associated file path being a file path having a containing relationship; the file path having the containing relationship comprises at least one child file path and one parent file path, and a scanning result corresponding to the child file path is notified to a scanning task corresponding to the parent file path; The scanning tasks corresponding to the associated file paths are merged; According to the merged scanning tasks, a file path is scanned to generate a file change record; the file change record is stored in a local database; a file synchronization version in the shared directory is updated; and based on the updated file synchronization version, the file change record and corresponding file content in the local database are synchronized to the trusted electronic device.
2. The method of claim 1, wherein, The merging of the scanning tasks corresponding to the associated file paths comprises the following steps: At least two scanning time intervals corresponding to the associated file paths are obtained; scanning time intervals corresponding to different file paths are different; The at least two scanning tasks corresponding to the associated file paths are merged into a target scanning task, and a target scanning time interval of the target scanning task is set according to the at least two scanning time intervals; the target scanning time interval is greater than or equal to the smallest scanning time interval in the at least two scanning time intervals and is less than the largest scanning time interval in the at least two scanning time intervals.
3. The method of claim 2, wherein, The method further comprises the following steps: According to the target scanning time interval, a file path corresponding to the target scanning task is scanned to obtain a scanning file, and the scanning file is used for synchronization to the at least one trusted electronic device.
4. The method of claim 2, wherein, The method further comprises the following steps: A to-be-scanned list is obtained, the to-be-scanned list comprising the associated file paths, file paths of unassociated scanning tasks and non-associated file paths of associated scanning tasks; According to the target scanning time interval, each file path in the to-be-scanned list is scanned, and a scanning result of any file path in the associated file paths is obtained when the any file path is scanned; The scanning result is fed back to a scanning task corresponding to each file path in the associated file paths.
5. The method of claim 3, wherein, The method further comprises the following steps: According to the target scanning time interval, a scanning start time of the target scanning task is set; When a current time reaches the scanning start time, scanning is started.
6. The method of claim 4, wherein, The feeding back of the scanning result to the scanning task corresponding to each file path in the associated file paths comprises the following steps: The scanning result is added to a preset notification list, and 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.
7. The method of claim 6, wherein, The method further includes: After scanning each file path in the to-be-scanned list, deleting all scanning results in the notification list.
8. The method of claim 6, wherein, The method further includes: After scanning any file path in the associated file paths, deleting the scanning result corresponding to the any file path in the notification list.
9. The method according to any one of claims 5 to 8, characterized in that, The method further includes: Obtaining a cancel scanning notification, the cancel scanning notification being used to cancel any scanning task corresponding to the associated file paths; Clearing the scanning start time of the target scanning task.
10. The method of claim 9, wherein, The clearing the scanning start time of the target scanning task includes: Determining that there is no containing relationship between other multiple file paths, the other multiple file paths being multiple file paths other than the file path corresponding to the any scanning task; Clearing the scanning start time of the target scanning task.
11. The method of claim 10, wherein, After obtaining the cancel scanning notification, the method further includes: Determining that there is a containing relationship between the other multiple file paths; Merging scanning tasks corresponding to the other multiple file paths having the containing relationship.
12. An electronic device, comprising: Comprise: One or more processors; one or more memories; The memory stores one or more programs, when the one or more programs are executed by the processor, the electronic device executes the method in any one of claims 1 to 11.
13. A chip, characterized by Comprise: A processor, configured to call and run a computer program from a memory, so that an electronic device installed with the chip executes the method in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, when the computer program is executed by the processor, the processor executes the method in any one of claims 1 to 11.
Citation Information
Patent Citations
Multimedia file scanning method and device and terminal equipment
CN114647746A