Hi,

On 16 Jan 2014, at 13:14, christopher.l...@thurweb.ch wrote:
> This gives the following Application Output:
> [D] main:42 - offlineStoragPath orig:  
> "/home/nemo/.local/share/CreateDBQt5/QML/OfflineStorage"
> [D] main:44 - offlineStoragPath new:  
> "/home/nemo/.local/share/landed25_QT5/QML/OfflineStorage"
> 
> The database is indeed created in 
> /home/nemo/.local/share/landed25_QT5/QML/OfflineStorage", and is accessible 
> to the app landed25_QT5
> 
> Note the order of the view->engine()->setOfflineStoragePath... and 
> view->setSource... calls is crucial. If the setSource comes first, then the 
> QML is initiated before the storagePath is changed!
> 
> In my next experiment I will try to change the storageLocation to something 
> like QStandardPaths::GenericDataLocation.
> 
> The question on harbour acceptability remains ...

For Harbour, using QStandardPaths should always be safe, but append the name of 
your application (harbour-myapp) to the path, so that all your 
application-specific data ends up there. Note that there is (in line with XDG) 
the data directory (where you store data, e.g. documents or something), the 
config directory (where you store configuration options, e.g. enabled/disabled 
states of features) and the cache directory (where you store data that can be 
safely deleted in case of low disk uage - e.g. user avatars from a web service 
or previews/thumbnails of documents, etc… - everything that can be re-created 
easily).

This is important, as this can be used in the future from a system service to 
calculate per-app disk usage and allow clearing of application data, 
integration with backup, etc… - also, it’s easier for power users to SSH into 
the device and find where their user data is. If you use QStandardPaths or XDG, 
you can be sure that if (when) the data location changes in the future, your 
application will still work correctly.

Absolute no-no: Hardcoding “/home/nemo/“ (if you need to find the user’s home 
directory, get the environment variable $HOME instead) and hardcoding the 
default values for the XDG data directories without looking up the environment 
variables ($XDG_DATA_HOME, $XDG_CONFIG_HOME, $XDG_CACHE_HOME) instead. Also 
no-no: Not using $APPNAME (harbour-myapp) as subdirectory of those XDG dirs. If 
$XDG_*_HOME is not set (and only then), fall back to the default paths as 
specified by XDG (e.g. $HOME/.config/ for $XDG_CONFIG_HOME, etc..). Or just use 
QStandardPaths, which will do The Right Thing(tm).

If we can fix the offline storage path to be correct everytime, we’ll probably 
introduce these changes into libsailfishapp, so that application developers 
don’t have to worry about manually setting this all the time (and you can still 
override this if you want, but you should not [need to]).


HTH :)
Thomas
_______________________________________________
SailfishOS.org Devel mailing list

Reply via email to