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
|
||||
return nil
|
||||
}
|
||||
|
@ -114,8 +114,9 @@
|
||||
<form class="pure-form gropple-config">
|
||||
<fieldset>
|
||||
<legend>Destinations</legend>
|
||||
<p>You can specify custom destinations here. You can specify that
|
||||
downloads be moved to one of these directories after complete.</p>
|
||||
<p>You can specify custom destinations (directories) here. Downloads can be
|
||||
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>
|
||||
<template x-for="(dest, i) in config.destinations">
|
||||
<div>
|
||||
@ -137,7 +138,7 @@
|
||||
</div>
|
||||
</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>
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user