Sanity check destinations
This commit is contained in:
parent
4f33603a0c
commit
f899b9c0c2
@ -175,6 +175,17 @@ func (c *Config) UpdateFromJSON(j []byte) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check destinations
|
||||||
|
for _, dest := range newConfig.Destinations {
|
||||||
|
s, err := os.Stat(dest.Path)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("destination '%s' (%s) is bad: %s", dest.Name, dest.Path, err)
|
||||||
|
}
|
||||||
|
if !s.IsDir() {
|
||||||
|
return fmt.Errorf("destination '%s' (%s) is not a directory", dest.Name, dest.Path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*c = newConfig
|
*c = newConfig
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,9 @@
|
|||||||
<form class="pure-form gropple-config">
|
<form class="pure-form gropple-config">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Destinations</legend>
|
<legend>Destinations</legend>
|
||||||
<p>You can specify custom destinations here. You can specify that
|
<p>You can specify custom destinations (directories) here. Downloads can be
|
||||||
downloads be moved to one of these directories after complete.</p>
|
moved to one of these directories after completion from the index page,
|
||||||
|
if you do not want them to be left in the download path above.</p>
|
||||||
</p>
|
</p>
|
||||||
<template x-for="(dest, i) in config.destinations">
|
<template x-for="(dest, i) in config.destinations">
|
||||||
<div>
|
<div>
|
||||||
@ -137,7 +138,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<button class="pure-button button-add" href="#" @click.prevent="config.destinations.push({name: 'new destination', path: '/'});">add destination</button>
|
<button class="pure-button button-add" href="#" @click.prevent="config.destinations.push({name: 'new destination', path: '/tmp'});">add destination</button>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user