Patent Publication Number: US-10776314-B2

Title: Electronic apparatus and method for temporarily storing data thereof

Description:
CROSS-REFERENCE TO RELATED APPLICATION 
     This application is a continuation application of and claims the priority benefit of U.S. patent application Ser. No. 14/735,170, filed on Jun. 10, 2015, now allowed, which claims the priority benefit of Taiwan application serial no. 104109984, filed on Mar. 27, 2015. The entirety of each of the above-mentioned patent applications is hereby incorporated by reference herein and made a part of this specification. 
    
    
     BACKGROUND 
     Field of the Invention 
     The invention relates to a method and an apparatus for data processing and more particularly, to an electronic apparatus and a method for temporarily storing data thereof. 
     Description of Related Art 
     With the development of cloud drives, users have become more and more accustomed to storing documents in the cloud drives. However, a speed of accessing the files through a network unavoidably cannot compare with a speed of accessing the local files. In order to resolve the issue, most cloud drive solutions that are currently available in the market provide a local cache mechanism. In this mechanism, files are pre-downloaded from a cloud drive to a local hard disk to provide a better accessing speed. 
     For instance, in Dropbox service provided by Dropbox Inc., all files are downloaded from a cloud drive to storage spaces of a local machine, which would occupy all available spaces when the local storage spaces are limited. On the other hand, in Google Drive service launched by Google Inc., all files are downloaded from a cloud drive to storage spaces of a local machine so that a user can choose not to synchronize part of the files. However, this design leads to two issues: (1) most users may not be aware of this setting; (2) the files that are chosen not to synchronize cannot be accessed on the apparatuses. 
     Moreover, in OneDrive service provided by Microsoft Corporation, a copy of metadata is downloaded for all files from a cloud drive to storage spaces of a local machine, instead of downloading complete copies of all files. The metadata is sufficient for the users to browse, and only when a user&#39;s demand for the content of a specific file is confirmed, the file content is downloaded. However, even though spaces for storing the metadata are smaller spaces for storing actual files, the storage spaces are still occupied when the amount of the files is too large. The design does not provide a clearing mechanism after the file content is downloaded. Therefore, with the increase of a usage time of the apparatus, the storage spaces are continuously occupied. When hardware venders continuously reduce storage spaces on apparatuses for saving cost, this storage mechanism is no longer feasible. 
     SUMMARY 
     Accordingly, the invention provides an electronic apparatus and a method for temporarily storing data thereof, through which files and metadata temporarily stored in the electronic apparatus are adaptively cleared and thus saving storage spaces occupied by the temporarily stored data. 
     According to an embodiment of the invention, a method for temporarily storing data, adapted for an electronic apparatus to temporarily store data downloaded from a remote apparatus, is provided. In the method, an access instruction to the remote apparatus is captured, and a file requested by the access instruction or metadata of all files and subfolders under a folder requested by the access instruction is accordingly downloaded from the remote apparatus. Then, the downloaded file or metadata is temporarily stored in a storage unit of the electronic apparatus, and a usage time of the temporarily stored file is recorded. Under a preset condition, the usage time of all the temporarily stored files is checked, at least one file having the longest usage time from a current time is accordingly deleted, whether the folder under which each of the detected files is located does not contain any file having the temporarily stored data is checked and the metadata of all the files and all the subfolders under the folder is accordingly deleted. 
     According to another embodiment of the invention, an electronic apparatus including a communication unit, a storage unit and a processing unit is provided. The communication unit is connected to a remote apparatus through network connection to download data. The storage unit is configured to temporarily store the data downloaded from the remote apparatus by the communication unit and store modules. The processing unit is coupled to the communication unit and the storage unit and configured to access and execute the modules in the storage unit. The modules include an instruction capturing module, a data downloading module and a data deleting module. The instruction capturing module captures an access instruction to the remote apparatus. The data downloading module downloads a file requested by the access instruction or metadata of all files and subfolders under a folder requested by the access instruction from the remote apparatus through the communication unit, temporarily stores the downloaded file or metadata in the storage unit and records a usage time of the temporarily stored file. The data deleting module checks, under a preset condition, the usage time of all temporarily stored files, accordingly deletes at least one file having the longest usage time from the current time, and checking whether the folder under which each of the detected files is located does not contain any file having the temporarily stored data and accordingly deletes the metadata of all the files and all the subfolders under the folder. 
     To sum up, the electronic apparatus of the invention captures the access instruction of a user to the electronic apparatus from a user from the remote apparatus and accordingly, accesses the data temporarily stored in a local end or downloads the desired data from the remote apparatus. For the folder accessed by the user, the electronic apparatus downloads the metadata of all the files and all the subfolders under the accessed folder from the remote apparatus and periodically clears the files and the folder that the files belong to which are not used for a long time. Thereby, the storage spaces occupied by the data temporarily stored in the electronic apparatus can be saved. 
     In order to make the aforementioned and other features and advantages of the invention more comprehensible, several embodiments accompanied with figures are described in detail below. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       The accompanying drawings are included to provide a further understanding of the invention, and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention. 
         FIG. 1  is a block diagram illustrating an electronic apparatus according to an embodiment of the invention. 
         FIG. 2  is a flowchart of a method for temporarily storing data of the electronic apparatus according to an embodiment of the invention. 
         FIG. 3   s  a flowchart of a method for temporarily storing data of the electronic apparatus according to an embodiment of the invention. 
         FIG. 4   s  a flowchart of a method for temporarily storing data of the electronic apparatus according to an embodiment of the invention. 
     
    
    
     DESCRIPTION OF EMBODIMENTS 
     The electronic apparatus of the present invention not only temporarily stores data of file that has been used by a user, but also stores metadata of all files and subfolders under a folder that has been used by the user. In addition, the electronic apparatus also records a file access history of the user and periodically clears the temporarily stored data of the files or the folders that have not been accessed for a long time in a local end. Thereby, limited storage spaces can be efficiently utilized for temporarily storing data to achieve balance between space demand and data access efficiency. 
       FIG. 1  is a block diagram illustrating an electronic apparatus according to an embodiment of the invention. Referring  FIG. 1 , an electronic apparatus  10  of the present embodiment is, for example, a portable electronic apparatus (e.g., a mobile phone, a smart phone, a personal digital assistance (PDA) or a tablet computer), a notebook computer, or a desktop computer, which is not limited in the invention. The electronic apparatus  10  includes a communication unit  12 , a storage unit  14  and a processing unit  16 , and functions thereof will be described below. 
     The communication unit  12  is, for example, a wireless network card complying with a wireless communication standard (e.g., the institute of electrical and electronics engineers (IEEE) standard) or a network card supporting wired network connection and may be connected with an external remote apparatus (not shown) through a network in a wireless or a wired manned. The remote apparatus is, for example, a server or a computer in a remote end, another mobile phone, another smart phone, another PDA or another tablet computer. 
     The storage unit  14  may be a fixed or a movable random access memory (RAM), read-only memory (ROM), flash memory or a similar component or a combination of those components. In the present exemplary embodiment, the storage unit  14  is configured to temporarily store data downloaded from the remote apparatus by the communication unit  12  and store programs of an instruction capturing module  142 , a data downloading module  144  and a data deleting module  146 . The storage unit  14  is not limited to a single storage element in the present exemplary embodiment, and each of the software modules may also be separately stored in two or more different storage elements of the same type or of different types. 
     The processing unit  16  is coupled to the communication unit  12  and the storage unit  14 . The processing unit  16  may be a single-core or a multi-core central processing unit (CPU), or any other programmable device for general purpose or special purpose, such as a digital signal processor (DSP), a programmable controller, an application specific integrated circuit (ASIC) or a combination of above-mentioned devices. In the present exemplary embodiment, the processing unit  16  is configured to access and execute the modules recorded in the storage unit  14 , so as to implement a method for temporarily storing data of the electronic apparatus  10  of the invention. The processing unit  16  of the present embodiment is not limited to a single processing element and may also include two or more processing elements to commonly execute the modules. 
       FIG. 2  is a flowchart of a method for temporarily storing data of the electronic apparatus according to an embodiment of the invention. Referring to  FIG. 1  and  FIG. 2  simultaneously, the method of the present embodiment is adapted to the electronic apparatus  10 , and the detailed process of the method of the present embodiment will be described with reference to each element of the electronic apparatus  10  illustrated in  FIG. 1 . 
     First, the instruction capturing module  142  captures an access instruction to a remote apparatus (not shown) from a user of the electronic apparatus  10 , and the data downloading module  144  accordingly downloads a file requested by the access instruction or metadata of all files and subfolders under a folder requested by the access instruction from the remote apparatus (step S 202 ). The metadata includes, for example, information for describing properties of data, such as files and folders and may serve as a basis for the electronic apparatus  10  to indicate a storage position, display historic data, search for a resource and record a file. When the user uses the electronic apparatus  10  to browse a file or a folder stored in the remote apparatus through a network, the data downloading module  144  may download metadata of data to be accessed, so as to provide information related to the file or the folder on the remote apparatus to the user, which helps the user to understand the information related to the file or the folder that the user is browsing. 
     Then, the data downloading module  144  temporarily stores the downloaded file or metadata in the storage unit  14  of the electronic apparatus  10  and records a usage time of the temporarily stored file in the storage unit  14  (step S 204 ). The usage time may serve as historic data of the user using each file and serve as a basis for the electronic apparatus  10  to subsequently clear the files. 
     It should be mentioned that in the present embodiment, the electronic apparatus  10  temporarily stores the metadata of the file or the folder browsed by the user in the storage unit  14 , such that the user may directly access the temporarily stored data when subsequently browsing the same data, thus accelerating the access. With the above temporary storage mechanism, when the instruction capturing module  142  captures the access instruction, the data downloading module  144  first checks whether data to be accessed by the access instruction is temporarily stored in the storage unit  14  so as to determine whether to read the required data directly from the storage unit  14  or to download the required data from the remote apparatus. In the meantime, the data downloading module  14  records the usage time of each file in the storage unit  14  and uses the usage time for subsequent file clearance. 
     For instance,  FIG. 3   s  a flowchart of a method for temporarily storing data of the electronic apparatus according to an embodiment of the invention. Referring to  FIG. 1  and  FIG. 3  simultaneously, the method of the present embodiment is adapted to the electronic apparatus  10 . It is assumed herein that the access instruction captured by the instruction capturing module  142  is to access a file of the remote apparatus, and when the instruction capturing module  142  captures the access instruction (step S 302 ), the data downloading module  144  first determines whether a file requested by the access instruction is temporarily stored in the storage unit  14  (step S 304 ). If recognizing that the file is temporarily stored in the storage unit  14 , the data downloading module  144  directly accesses the storage unit  14  to obtain the file and meanwhile, updates a usage time of the file (step S 306 ). Otherwise, if recognizing that the file is not temporarily stored in the storage unit  14 , the data downloading module  144  turns to connect to the remote apparatus through the communication unit  12  to download the file from the remote apparatus (step S 308 ) and temporarily stores the downloaded file in the storage unit  14  (step S 310 ). Lastly, the data downloading module  144  may provide the data requested by the access instruction (step S 312 ) through opening a file or displaying a folder, for example. With the method for temporarily storing data of the present embodiment, the electronic apparatus  10  can efficiently utilize the storage unit  14  to improve the data access efficiency. 
     On the other hand,  FIG. 4  is a flowchart of a method for temporarily storing data of the electronic apparatus according to an embodiment of the invention. Referring to  FIG. 1  and  FIG. 4  simultaneously, the method of the present embodiment is adapted to the electronic apparatus  10 . It is assumed herein that the access instruction captured by the instruction capturing module  142  is to access a folder of files, and when the instruction capturing module  142  captures the access instruction (step S 402 ), the data downloading module  144  first determines whether metadata of all files and subfolders under the folder requested by the access instruction is temporarily stored in the storage unit  14  (step S 404 ). If recognizing that the metadata is temporarily stored in the storage unit  14 , the data downloading module  144  directly accesses the storage unit  14  to obtain the metadata (step S 406 ). Otherwise, if recognizing that the metadata is not temporarily stored in the storage unit  14 , the data downloading module  144  turns to connect to the remote apparatus through the communication unit  12  to download the metadata from the remote apparatus (step S 408 ) and temporarily stores the downloaded metadata in the storage unit  14  (step S 410 ). Lastly, the data downloading module  144  may provide the metadata requested by the access instruction (step S 412 ) through displaying information related to the files or the folder, for example. With the method for temporarily storing data of the present embodiment, the electronic apparatus  10  can efficiently utilize the storage unit  14  to improve the data access efficiency. 
     Returning to the flow illustrated in  FIG. 2 , after the data downloading module  144  temporarily stores the downloaded file or metadata in the storage unit  14  of the electronic apparatus  10 , under a preset condition, the data deleting module  146  checks the usage times of all the files temporarily stored in the storage unit  14  and accordingly deletes at least one file having the longest usage time from the present (step S 206 ). In detail, in an embodiment, the data deleting module  146  may periodically activate a clearance procedure, for example, per a preset time period (e.g., one week, one month or other times) to automatically clear the data of the files temporarily stored in the storage unit  14  that are not accessed by the user for a long time. In another embodiment, the data deleting module  146  may activate the clearance procedure when a space occupied by the temporarily stored data in the storage unit  14  is over a preset space. The preset condition is illustrated as examples, and technicians of the art may set different conditions for activating the clearance process depending on actual needs, which is not limited in the invention. Additionally, in the preceding step, the data deleting module  146  only deletes the data of the file, but keeps the metadata of the file, such that the user still can browse the information related to the file even offline (i.e., no network is connected). 
     After deleting the file, the data deleting module  146  further checks whether the folder where each deleted file is located does not contain any file having a temporarily stored data and accordingly, deletes the metadata of all the files and all the subfolders under the folder (step S 208 ). To be detailed, when the user does not access a specific file for a long time, it indicates that an opportunity of accessing the folder where the file is located is also relatively low, and thus, whenever deleting a file having the temporarily stored data, the data deleting module  146  checks whether there are other files having the temporarily stored data in the folder under which the file is located. If the folder does not contain any file having the temporarily stored data, it may be determined that the opportunity of the user subsequently accessing the folder is low, and the metadata of all the files and al the subfolders under the folder is deleted to save the storage space of the storage unit  14 . 
     It should be mentioned that in a folder structure using a tree structure, whenever temporarily stored data of a file is deleted, not only a folder that the file belongs to may contain no file having the temporarily stored data, but also an upper folder of the folder may contain no file having the temporarily stored data. Accordingly, after the step of deleting the metadata of all the files and all the subfolders under the folder, the data deleting module  146  further recursively checks whether an upper folder of the folder does not contain any file having the temporarily stored data and accordingly deletes the metadata of all the files and all the subfolders under the upper folder. The data deleting module  146  continues to check each upper folder layer by layer until reaches an upper folder containing files having the temporarily stored data. 
     With the method for temporarily storing data, the electronic apparatus of the embodiment of the invention may adaptively delete the metadata of temporarily stored files or folders according to a historic log of the user accessing the files or the folders, such that the storage spaces may be efficiently utilized to enhance data access efficiency. 
     In view of the foregoing, in the electronic apparatus and the method for temporarily storing data thereof of the invention, the files stored in a cloud drive is downloaded in an on demand manner, such that the electronic apparatus equipped with a small-capacity storage space can also retain the data access efficiency while accessing a large amount of data in the cloud drive. Moreover, in the invention, the temporarily stored file or metadata are periodically cleared according the usage record of the file, such that the storage space of the electronic apparatus can be effectively utilized, so as to achieve balance between the space demand and the data access efficiency. 
     Although the invention has been described with reference to the above embodiments, it will be apparent to one of the ordinary skill in the art that modifications to the described embodiment may be made without departing from the spirit of the invention. Accordingly, the scope of the invention will be defined by the attached claims not by the above detailed descriptions.