2020-02-21 06:36:55 +00:00
|
|
|
const State = require('../State')
|
|
|
|
|
|
|
|
class DirectoryState extends State {
|
|
|
|
async apply() {
|
|
|
|
if ( !(await this.check()) ) {
|
|
|
|
const path = await this._path()
|
|
|
|
await path.touch(true)
|
2020-02-27 06:31:07 +00:00
|
|
|
|
|
|
|
// TODO directories
|
2020-02-21 06:36:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async check() {
|
|
|
|
const path = await this._path()
|
|
|
|
await path.classify()
|
|
|
|
return path.is_directory()
|
|
|
|
}
|
|
|
|
|
|
|
|
async reverse() {
|
|
|
|
if ( await this.check() ) {
|
|
|
|
const path = await this._path()
|
|
|
|
await path.unlink()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async _path() {
|
|
|
|
return this._host.get_path(this._config.path)
|
|
|
|
}
|
2020-04-15 14:11:10 +00:00
|
|
|
|
|
|
|
failure_message() {
|
|
|
|
return `The path "${this._config.path}" does not exist on host "${this._host.name}."`
|
|
|
|
}
|
|
|
|
|
|
|
|
check_message() {
|
|
|
|
return this.failure_message()
|
|
|
|
}
|
2020-02-21 06:36:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = DirectoryState
|