Comments (6)
Hi all. I like the idea of using the XDG specification, of course falling back to previous directory for backwards compatibility.
I would use XDG_DATA_HOME
because:
XDG_STATE_HOME
is more unused, and added in a next revision in 2021: Free Desktop 0.8- I found it more relevant and it's used widely by other applications. In this case, the specification is not clear on what data and state means.
Please let me know your thoughts.
from cotp.
Implemented in #337
from cotp.
Hello, @tomasol,
The App itself already supports to read an environment variable named COTP_DB_PATH
. I'm not sure if this meets your needs...
cotp supports portable mode and specify of the db location:
The app will check the COTP_DB_PATH
variable 1st, then check the .cotp/db.cotp
in the App folder(working directory), and finally the default path of the user folder.(%userprofile%\.cotp\db.cotp
on Windows, the ~/.cotp/db.cotp
on Linux)
TLDR: to use portable mode, make sure .cotp
folder exists at the same place where the App executable is.
from cotp.
Having the app specific COTP_DB_PATH
is nice for some use cases, but that isn't a substitute for XDG support, which should come first. The hard coded .cotp/db.cotp
should be preceded by a check for if a relevant XDG variable is set, and use it if it is, and probably then default to .local/share
if it isn't instead of .cotp
.
- If
COTP_DB_PATH
is set, use that as the full path. - If
$(pwd)/.cotp
exists, use that prefix for portability mode. - If
~/.cotp
exists, use that prefix for backwards compatibility but warn the default location has changed. - Check if
XDG_DATA_HOME
is set, if so use it as prefix with$XDG_DATA_HOME/cotp
. - If not, set the hard coded prefix to
.local/share/cotp
from cotp.
@PM2p5 here is a writeup regarding why following the XDG specification might be beneficial.
@alerque I agree with your proposal.
One thing that I might have gotten wrong is the category to which the database belongs to:
From the spec:
There is a single base directory relative to which user-specific data files should be written. This directory is defined by the environment variable $XDG_DATA_HOME.
There is a single base directory relative to which user-specific state data should be written. This directory is defined by the environment variable $XDG_STATE_HOME.
XDG_DATA_HOME
Where user-specific data files should be written (analogous to /usr/share).
Should default to $HOME/.local/share.
XDG_STATE_HOME
Where user-specific state files should be written (analogous to /var/lib).
Should default to $HOME/.local/state.
And finally xdgbasedirectoryspecification.com
Data
General files and data that is inherently portable across computers. Examples include fonts, files downloaded from the internet, and desktop entries.
State
Files that hold the state of the application. This may include logs, command history, recently used files, and game save data. In other words, if the data is unique for a given machine, the file belongs here.
Now I think it should be in XDG_STATE_HOME
rather than XDG_DATA_HOME
. WYT?
from cotp.
I have heard several explanations and not all of them agree with each other. In fact some conflict. For example one way of drawing a line between them I've heard and see used is that STATE is for transitive data that is only relevant while an instance of a program is actively running, and DATA is for anything that should persist across app runs, reboots, etc.
That's inconsistent with the explanations you posted, but either way in both cases I don't think the COTP database qualifies as state. It is a data file with stuff that may be synchronized across machines, it is not specific to one application runtime, user login session, or even computer.
from cotp.
Related Issues (20)
- Error editing entry HOT 4
- Use color-eyre crate for error handling
- Configure Cache in CI/CD
- Use once_cell crate for lazy initialization
- Export to widely know format HOT 3
- Migrate to ratatui as tui-rs is unmainteined
- [Feature request] Is it possible to add URI string format support for both import and export HOT 13
- [Feature request] Is it possible to support some kind(s) portable mode? HOT 11
- [Feature request] Is it possible to add a Page Up/Down page navigation feature for the UI HOT 1
- Chromium 117 freezes for several seconds when attempting to paste the token
- Minor typo s/chages/changes HOT 1
- convert export.cotp HOT 7
- The automated release is failing 🚨
- How can I use Cotp with Microsoft Teams? HOT 1
- Should downstream packaging include importers? HOT 4
- Feature Request: A way to share HOTP/TOTP URI outside of QR encoding HOT 2
- No way to import OTP URIs as strings (from stdin or arguments) without files HOT 4
- `cotp import --otp-uri --path [file]` doesn't seem to work HOT 2
- Feature request: add subcomannd `list` to list entries HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cotp.