Skip to content

LiquidCore File System

Eric Lange edited this page Feb 8, 2019 · 3 revisions

Virtual File System

A micro service namespace is uniquely referenced by its URI path (excluding the filename). This allows multiple instances of a micro service, or even different micro services (with different filenames in the same path) to share data between them. In web terms, this acts like the cookie space to ensure that micro services from different providers remain isolated from each other.

Some definitions:

Host: The hosting app -- that is, the native Android/iOS app that includes the LiquidCore library.

Micro service: A Node.js module whose code is referenced by a URI

Instance: A single instance of a micro service. Each instance operates in its own thread and in its own Node.js environment. Two instances of the same micro service are independent of each other, except that they share a virtual file system.

Namespace: A namespace, specified by the path of the micro service URI, identifies which micro services share a virtual file system. Namespaces are not hierarchical. For example, http://foo.org/a and http://foo.org/a/b are two completely different namespaces; one does not inherit from another.

Each namespace its own virtual file system, but can share files between instances running in the same namespace on the same host (via /home/local or /home/cache), or make them publicly available (via /home/public). The directory structure is as follows:

home
  |
  +--- node_modules
  |
  +--- module
  |
  +--- temp
  |
  +--- cache
  |
  +--- local
  |
  +--- public
         |
         +--- data
         |
         +--- media (Android only)
                |
                +--- Pictures
                |
                +--- Movies
                |
                +--- Ringtones
                |
                +--- ...

/home

Read-only directory which acts only as a holding bin for other directories

/home/node_modules

Read-only directory containing references to native add-on modules. These modules can be loaded using require(). These modules are in addition to the standard built-in Node.js modules.

/home/module

Read-only directory. Contains downloaded javascript code for the micro service. As these files change on the server, they will be updated and cached here.

/home/temp

Read/write directory. This directory is private to a single instance of a micro service. The contents of this directory live only as long as the underlying Node.js process is active. This directory is appropriate only for very short-lived temporary files.

/home/cache

Read/write directory. This directory is available to all micro service instances running in the same namespace on the same local host. The host is the host app which uses an instance of the LiquidCore library. Files in this directory will be deleted on an as-needed basis as they age and/or a memory space quota is breaching.

/home/local

Read/write directory. This directory is the persistent storage for a namespace and is shared amongst all instances running in the same namespace and on the same local host. All content in this directory will persist so long as a micro service in this namespace is installed on the host. This directory will only be cleared when all micro services in the namespace are "uninstalled". Uninstallation happens for micro services that have not been used in a long time and when space is required for installing new micro services.

/home/public

Read-only directory which acts as a holding bin for other public directories. This directory may not exist if no external (SD card) storage is available.

/home/public/data

Read/write directory for namespace-specific data. On Android, this directory is shared between all instances of a micro service namespace on all hosts (local or not). On iOS, this directory is shared between all instances of a micro service namespace on the local host only (iOS limitation). Its contents are publicly available for any app (or in the case of iOS, the host app only) to access, though its true location on external media is somewhat obscured. This directory persists so long as a namespace micro service is still installed on any host. If all micro services in a given namespace are uninstalled from every host, this directory will also be cleared.

/home/public/media

Read-only holding directory for public media-specific directories. Only available on Android.

/home/public/media/[MediaType]

Read or read/write directory (depending on permissions given by the host) for known media types. These types include Pictures, Movies, Ringtones, Music, Downloads, etc. as exposed by Android and typically reside at a true location like /sdcard/Pictures, for example. Files in these directories are never cleared by LiquidCore, but can be managed by any other app or service.

Everything else will result in an ENOACES (access denied) error.