-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
97 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* S3pool - S3 cache on local disk | ||
* Copyright (c) 2019 CK Tan | ||
* [email protected] | ||
* | ||
* S3Pool can be used for free under the GNU General Public License | ||
* version 3, where anything released into public must be open source, | ||
* or under a commercial license. The commercial license does not | ||
* cover derived or ported versions created by third parties under | ||
* GPL. To inquire about commercial license, please send email to | ||
* [email protected]. | ||
*/ | ||
package conf | ||
|
||
var Verbose int | ||
var RefreshInterval = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* S3pool - S3 cache on local disk | ||
* Copyright (c) 2019 CK Tan | ||
* [email protected] | ||
* | ||
* S3Pool can be used for free under the GNU General Public License | ||
* version 3, where anything released into public must be open source, | ||
* or under a commercial license. The commercial license does not | ||
* cover derived or ported versions created by third parties under | ||
* GPL. To inquire about commercial license, please send email to | ||
* [email protected]. | ||
*/ | ||
package op | ||
|
||
import ( | ||
"errors" | ||
"s3pool/conf" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func strtobool(s string) bool { | ||
return s == "true" || s == "1" || s == "on" | ||
} | ||
|
||
func Set(args []string) (string, error) { | ||
if len(args) != 2 { | ||
return "", errors.New("expects 2 arguments for SET") | ||
} | ||
varname, varvalue := strings.ToLower(args[0]), strings.ToLower(args[1]) | ||
|
||
if varname == "verbose" { | ||
i, err := strconv.Atoi(varvalue) | ||
if err != nil { | ||
return "", err | ||
} | ||
conf.Verbose = i | ||
return "\n", nil | ||
} | ||
|
||
if varname == "refresh_interval" { | ||
i, err := strconv.Atoi(varvalue) | ||
if err != nil { | ||
return "", err | ||
} | ||
conf.RefreshInterval = i | ||
return "\n", nil | ||
} | ||
|
||
return "", errors.New("Unknown var name") | ||
} |