2019-07-17 22:25:42 +00:00
|
|
|
// Code generated by go-bindata. DO NOT EDIT.
|
|
|
|
// sources:
|
2020-01-10 18:59:01 +00:00
|
|
|
// 000001_init.down.db.sql (65B)
|
|
|
|
// 000001_init.up.db.sql (2.693kB)
|
2019-07-17 22:25:42 +00:00
|
|
|
// doc.go (377B)
|
|
|
|
|
2019-07-30 06:14:13 +00:00
|
|
|
package migrations
|
2019-07-17 22:25:42 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"compress/gzip"
|
|
|
|
"crypto/sha256"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func bindataRead(data []byte, name string) ([]byte, error) {
|
|
|
|
gz, err := gzip.NewReader(bytes.NewBuffer(data))
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("read %q: %v", name, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var buf bytes.Buffer
|
|
|
|
_, err = io.Copy(&buf, gz)
|
|
|
|
clErr := gz.Close()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("read %q: %v", name, err)
|
|
|
|
}
|
|
|
|
if clErr != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf.Bytes(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type asset struct {
|
|
|
|
bytes []byte
|
|
|
|
info os.FileInfo
|
|
|
|
digest [sha256.Size]byte
|
|
|
|
}
|
|
|
|
|
|
|
|
type bindataFileInfo struct {
|
|
|
|
name string
|
|
|
|
size int64
|
|
|
|
mode os.FileMode
|
|
|
|
modTime time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fi bindataFileInfo) Name() string {
|
|
|
|
return fi.name
|
|
|
|
}
|
|
|
|
func (fi bindataFileInfo) Size() int64 {
|
|
|
|
return fi.size
|
|
|
|
}
|
|
|
|
func (fi bindataFileInfo) Mode() os.FileMode {
|
|
|
|
return fi.mode
|
|
|
|
}
|
|
|
|
func (fi bindataFileInfo) ModTime() time.Time {
|
|
|
|
return fi.modTime
|
|
|
|
}
|
|
|
|
func (fi bindataFileInfo) IsDir() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
func (fi bindataFileInfo) Sys() interface{} {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-01-10 18:59:01 +00:00
|
|
|
var __000001_initDownDbSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\x09\xf2\x0f\x50\x08\x71\x74\xf2\x71\x55\x48\xce\x48\x2c\x29\xb6\xe6\x42\x12\x29\x2d\x4e\x2d\x8a\xcf\x4d\x2d\x2e\x4e\x4c\x4f\x45\x95\x49\xce\xcf\x2b\x49\x4c\x06\x29\x07\x04\x00\x00\xff\xff\x61\x86\xbd\x5f\x41\x00\x00\x00")
|
2019-07-17 22:25:42 +00:00
|
|
|
|
2019-07-26 07:17:29 +00:00
|
|
|
func _000001_initDownDbSqlBytes() ([]byte, error) {
|
2019-07-17 22:25:42 +00:00
|
|
|
return bindataRead(
|
2019-07-26 07:17:29 +00:00
|
|
|
__000001_initDownDbSql,
|
|
|
|
"000001_init.down.db.sql",
|
2019-07-17 22:25:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-07-26 07:17:29 +00:00
|
|
|
func _000001_initDownDbSql() (*asset, error) {
|
|
|
|
bytes, err := _000001_initDownDbSqlBytes()
|
2019-07-17 22:25:42 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-01-10 18:59:01 +00:00
|
|
|
info := bindataFileInfo{name: "000001_init.down.db.sql", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1577718673, 0)}
|
|
|
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5e, 0xbb, 0x3f, 0x1, 0x75, 0x19, 0x70, 0x86, 0xa7, 0x34, 0x40, 0x17, 0x34, 0x3e, 0x18, 0x51, 0x79, 0xd4, 0x22, 0xad, 0x8f, 0x80, 0xcc, 0xa6, 0xcc, 0x6, 0x2b, 0x62, 0x2, 0x47, 0xba, 0xf9}}
|
2019-07-17 22:25:42 +00:00
|
|
|
return a, nil
|
|
|
|
}
|
|
|
|
|
2020-01-10 18:59:01 +00:00
|
|
|
var __000001_initUpDbSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x56\x51\x6f\xe3\x36\x0c\x7e\xf7\xaf\x20\xb0\x87\xb6\x80\x3b\xdc\x80\xdb\x6d\x40\x9f\xd2\x9e\xbb\x05\xcb\x92\x43\xea\x0e\xbd\x27\x81\x91\xd8\x58\x88\x2d\x19\x12\x9d\x5c\x80\xfb\xf1\x83\x9c\x38\xb1\x12\xa7\xbd\x61\x7d\x28\x5a\x52\x24\xc5\x8f\xfc\x3e\xf9\x61\x9e\x8d\xf2\x0c\xf2\xd1\xfd\x24\x83\xf1\x23\x4c\x67\x39\x64\x2f\xe3\xa7\xfc\x09\x64\x81\xec\xe1\x3a\xd1\x0a\xfe\x19\xcd\x1f\xfe\x1c\xcd\xe1\xcb\x7c\xfc\xf7\x68\xfe\x15\xfe\xca\xbe\xc2\x6c\x0a\x0f\xb3\xe9\xe3\x64\xfc\x90\xc3\x3c\xfb\x32\x19\x3d\x64\x69\x62\xb0\xa2\xc3\xe9\x90\x6b\xfa\x3c\x99\xa4\x89\xb4\xa5\x75\x67\x76\xf8\x9c\x3d\x8e\x9e\x27\x39\x5c\xfd\x84\xbf\xfc\xfe\x9b\xfa\xf5\x2a\x4d\x78\x5b\x13\x8c\xa7\x79\x2f\x18\x25\xeb\x35\xc1\xfd\x6c\x36\xc9\x46\xd3\xf3\xe8\x7c\xfe\x9c\xa5\x09\xeb\x8a\x3c\x63\x55\x9f\x44\x2b\x2a\x89\x49\x09\x64\x21\x4b\x2b\x57\x62\x8d\x65\x13\x97\x38\x64\xfa\x90\x26\x75\xb3\x28\xb5\x14\x2b\xda\xc2\xfd\x64\x76\x9f\x26\x8d\x59\x6b\xda\x90\x12\x15\x79\x8f\x4b\x12\xd2\x36\x86\x2f\xc6\x97\xe8\x7f\xac\x50\x7b\x70\x9f\x73\x5f\xaa\xa2\x6a\x41\xce\xc7\xff\x15\xba\x16\x4d\xad\x90\x69\xe7\x48\x6e\xee\x92\x24\x9a\x9a\xb4\x86\x51\xb6\xa3\x02\xd0\x0a\xf2\xec\x25\x7f\x7f\x52\x00\xa8\x94\x23\xef\x77\xe7\x8f\x80\x01\xb4\x43\x3c\xb3\x92\xf1\x62\x4d\x4e\xbf\x6a\x52\x87\x61\x74\x0d\x3d\x8e\x26\x4f\xd9\xe9\x29\x81\x97\x71\x02\xc0\x52\xe3\x40\x71\xad\xc8\xb0\x96\xd6\x9c\xbb\xea\xc2\xb2\x3d\x37\xb7\x48\xee\x20\x52\x6f\xd4\xf3\x5b\xcf\x54\x09\xc6\x65\x87\x30\x80\xa2\xb5\x96\x24\xb4\x79\xb5\x07\x1b\x3b\xbd\x68\x98\x04\x5b\xc1\x58\xae\xe2\x7a\x2d\xfa\xb7\xb7\x30\xe6\x2b\x0f\xba\xaa\xad\x63\x34\x0c\x5c\x60\xf8\xa5\x3d\x30\x2e\x4a\x82\x02\x3d\x38\xbb\xd1\x0a\xd0\xc3\x86\xc0\x51\xb9\x05\x6b\x40\x73\x08\xde\x14\x64\x42\x70\x49\x55\xe8\xd5\x2c\x41\x9b\x57\x6d\x34\xd3\xad\x97\xce\x96\xe5\xcf\xc9\x1b\xb4\x6c\x3c\xb9\x6e\x71\x76\x33\x6f\xa7\xfe\xc3\x14\x0d\xe7\x37\x85\xf6\x35\x39\x11\x91\x26\xfb\x23\x9b\x47\xc0\x02\x78\xdb\x38\x39\xb0\x0b\x01\x39\xcf\xda\x20\x6b\x6b\x0e\xc8\x01\x30\x7d\xe3\x01\xfa\x07\x57\xd8\x52\x32\x2c\x06\x08\x1e\xdc\xa1\xab\xbe\x78\xec\xf3\x5d\x20\x75\x9b\xb0\x40\x16\xbd\xc6\x63\x6f\x69\x25\x96\xe2\xed\x33\x85\x56\x74\x79\x93\x01\x1c\xf9\xda\x1a\x1f\x56\x21\xbe\x56\x27\x05\x5d\x2f\xfb\x0b\x5d\x60\xfd\x1e\x4a\x22\x73\x59\xc3\x7a\x55\x6d\xc3\x4b\xab\xcd\x52\x78\x46\x6e\x7c\x5c\xb9\x46\xe7\x49\x89\x16\xe7\x23\xec\x0e\x37\xa2\xc6\x6d\x69\x51\xf5\xac\x9e\xb5\x5c\x91\x13\x35\xca\xd5\xf1\x96\x9d\xb5\x40\x5f\xc4\xb9\xa5\xad\x2a\x34\xaa\x87\x57\x6c\xdf\x75\x36\xe8\xea\xa4\x64\xd0\xf9\xea\x6c\x35\xec\x09\x3b\xe1\x50\xf2\xb0\x97\x1d\x1a\x1f\xc4\xdf\x9a\x37\x6e\xeb\xf5\xd2\x20\x37\x8e\x7a\x9d\x1f\x7c\x8c\xdc\xce\xa2\x2f\x9a\xe3\xe9\xe7\xec\x05\xb4\xfa\x26\xf6\xdb\x3d\x9b\xc6\x9c\xba\xde\xd9\x6f\xee\x06\x22\x08\x9d\x2c\xc4\x62\x7b\xd8\xac\xd9\x14\x4e\xa2\x77\x28\x37\x0b\xcf\xee\xfa\xea\xc3\xff\xfc\xb9\x82\xef\xdf\xfb\x8b\x95\xc2\xed\xa7\x8f\x29\x7c\xfa\x78\x13\x1c\x5a\xa5\x1d\x0d\xd2\x76\x9b\xcf\x1f\x87\x58\x3b\xc2\xa2\x44\xd2\xf1\xdf\x84\xe3\x7d\x52\xb5\x5a\xec\xe9\xe4\x81\x6c\xe5\x97\xda\x81\x9f\xbe\x9d\x7b\x17\x5f\xe6\xa1\xa3\x36\x14\x1b\xb6\x15\xb2\x96\x58\x96\xdb\xcb\xa7\x87\xa8\xe9\x48\xea\x5a\x93\xe1\xa3\xf0\xf7\xd9\xf2\x0e\x66\x21\x23\x99\x65\x50\xcb\xe3\x42\xfa\xf0\x3c\xac\xb1\xd4\xe1\xd5\x69\x91\xec\x0a\xc7\xec\x39\xe7\x54\xd4\xf9\xa5\x15\xef\x0f\x63\xd7\x01\xbb\xed\x11\xbd\x60\x7a\xd5\xae\x85\x9a\x4c\x67\x89\x99\x10\xd7\xe9\x5d\xf6\x14\xba\xdd\xe7\x13\xc0\xc9\x97\xcf\x20\x63\x06\xb1\x88\xa0\x08\x7c\x78\x1f\xb1\xeb\xde\xdf\x37\x77\xc9\xbf\x01\x00\x00\xff\xff\xc7\x20\x3e\x09\x85\x0a\x00\x00")
|
2019-07-17 22:25:42 +00:00
|
|
|
|
2019-07-26 07:17:29 +00:00
|
|
|
func _000001_initUpDbSqlBytes() ([]byte, error) {
|
2019-07-17 22:25:42 +00:00
|
|
|
return bindataRead(
|
2019-07-26 07:17:29 +00:00
|
|
|
__000001_initUpDbSql,
|
|
|
|
"000001_init.up.db.sql",
|
2019-07-17 22:25:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-07-26 07:17:29 +00:00
|
|
|
func _000001_initUpDbSql() (*asset, error) {
|
|
|
|
bytes, err := _000001_initUpDbSqlBytes()
|
2019-07-17 22:25:42 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-01-10 18:59:01 +00:00
|
|
|
info := bindataFileInfo{name: "000001_init.up.db.sql", size: 2693, mode: os.FileMode(0644), modTime: time.Unix(1577718868, 0)}
|
|
|
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x34, 0x9f, 0x6, 0x64, 0xcf, 0x97, 0xbe, 0xa8, 0xa2, 0x2f, 0xda, 0xc5, 0x9d, 0x26, 0x3, 0x65, 0x98, 0x8a, 0x7a, 0x6a, 0xc3, 0xd, 0x3f, 0x25, 0xfe, 0x4c, 0x5, 0xdb, 0x98, 0xa9, 0xf9, 0xf}}
|
2019-08-06 21:50:13 +00:00
|
|
|
return a, nil
|
|
|
|
}
|
|
|
|
|
2019-07-30 06:14:13 +00:00
|
|
|
var _docGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x8f\xbb\x6e\xc3\x30\x0c\x45\x77\x7f\xc5\x45\x96\x2c\xb5\xb4\x74\xea\xd6\xb1\x7b\x7f\x80\x91\x68\x89\x88\x1e\xae\x48\xe7\xf1\xf7\x85\xd3\x02\xcd\xd6\xf5\x00\xe7\xf0\xd2\x7b\x7c\x66\x51\x2c\x52\x18\xa2\x68\x1c\x58\x95\xc6\x1d\x27\x0e\xb4\x29\xe3\x90\xc4\xf2\x76\x72\xa1\x57\xaf\x46\xb6\xe9\x2c\xd5\x57\x49\x83\x8c\xfd\xe5\xf5\x30\x79\x8f\x40\xed\x68\xc8\xd4\x62\xe1\x47\x4b\xa1\x46\xc3\xa4\x25\x5c\xc5\x32\x08\xeb\xe0\x45\x6e\x0e\xef\x86\xc2\xa4\x06\xcb\x64\x47\x85\x65\x46\x20\xe5\x3d\xb3\xf4\x81\xd4\xe7\x93\xb4\x48\x46\x6e\x47\x1f\xcb\x13\xd9\x17\x06\x2a\x85\x23\x96\xd1\xeb\xc3\x55\xaa\x8c\x28\x83\x83\xf5\x71\x7f\x01\xa9\xb2\xa1\x51\x65\xdd\xfd\x4c\x17\x46\xeb\xbf\xe7\x41\x2d\xfe\xff\x11\xae\x7d\x9c\x15\xa4\xe0\xdb\xca\xc1\x38\xba\x69\x5a\x29\x9c\x29\x31\xf4\xab\x88\xf1\x34\x79\x9f\xfa\x5b\xe2\xc6\xbb\xf5\xbc\x71\x5e\xcf\x09\x3f\x35\xe9\x4d\x31\x77\x38\xe7\xff\x80\x4b\x1d\x6e\xfa\x0e\x00\x00\xff\xff\x9d\x60\x3d\x88\x79\x01\x00\x00")
|
2019-07-17 22:25:42 +00:00
|
|
|
|
|
|
|
func docGoBytes() ([]byte, error) {
|
|
|
|
return bindataRead(
|
|
|
|
_docGo,
|
|
|
|
"doc.go",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func docGo() (*asset, error) {
|
|
|
|
bytes, err := docGoBytes()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
Move to protobuf for Message type (#1706)
* Use a single Message type `v1/message.go` and `message.go` are the same now, and they embed `protobuf.ChatMessage`
* Use `SendChatMessage` for sending chat messages, this is basically the old `Send` but a bit more flexible so we can send different message types (stickers,commands), and not just text.
* Remove dedup from services/shhext. Because now we process in status-protocol, dedup makes less sense, as those messages are going to be processed anyway, so removing for now, we can re-evaluate if bringing it to status-go or not.
* Change the various retrieveX method to a single one:
`RetrieveAll` will be processing those messages that it can process (Currently only `Message`), and return the rest in `RawMessages` (still transit). The format for the response is:
`Chats`: -> The chats updated by receiving the message
`Messages`: -> The messages retrieved (already matched to a chat)
`Contacts`: -> The contacts updated by the messages
`RawMessages` -> Anything else that can't be parsed, eventually as we move everything to status-protocol-go this will go away.
2019-12-05 16:25:34 +00:00
|
|
|
info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)}
|
2019-07-30 06:14:13 +00:00
|
|
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xef, 0xaf, 0xdf, 0xcf, 0x65, 0xae, 0x19, 0xfc, 0x9d, 0x29, 0xc1, 0x91, 0xaf, 0xb5, 0xd5, 0xb1, 0x56, 0xf3, 0xee, 0xa8, 0xba, 0x13, 0x65, 0xdb, 0xab, 0xcf, 0x4e, 0xac, 0x92, 0xe9, 0x60, 0xf1}}
|
2019-07-17 22:25:42 +00:00
|
|
|
return a, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Asset loads and returns the asset for the given name.
|
|
|
|
// It returns an error if the asset could not be found or
|
|
|
|
// could not be loaded.
|
|
|
|
func Asset(name string) ([]byte, error) {
|
|
|
|
canonicalName := strings.Replace(name, "\\", "/", -1)
|
|
|
|
if f, ok := _bindata[canonicalName]; ok {
|
|
|
|
a, err := f()
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
|
|
|
|
}
|
|
|
|
return a.bytes, nil
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("Asset %s not found", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AssetString returns the asset contents as a string (instead of a []byte).
|
|
|
|
func AssetString(name string) (string, error) {
|
|
|
|
data, err := Asset(name)
|
|
|
|
return string(data), err
|
|
|
|
}
|
|
|
|
|
|
|
|
// MustAsset is like Asset but panics when Asset would return an error.
|
|
|
|
// It simplifies safe initialization of global variables.
|
|
|
|
func MustAsset(name string) []byte {
|
|
|
|
a, err := Asset(name)
|
|
|
|
if err != nil {
|
|
|
|
panic("asset: Asset(" + name + "): " + err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
|
|
|
// MustAssetString is like AssetString but panics when Asset would return an
|
|
|
|
// error. It simplifies safe initialization of global variables.
|
|
|
|
func MustAssetString(name string) string {
|
|
|
|
return string(MustAsset(name))
|
|
|
|
}
|
|
|
|
|
|
|
|
// AssetInfo loads and returns the asset info for the given name.
|
|
|
|
// It returns an error if the asset could not be found or
|
|
|
|
// could not be loaded.
|
|
|
|
func AssetInfo(name string) (os.FileInfo, error) {
|
|
|
|
canonicalName := strings.Replace(name, "\\", "/", -1)
|
|
|
|
if f, ok := _bindata[canonicalName]; ok {
|
|
|
|
a, err := f()
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
|
|
|
|
}
|
|
|
|
return a.info, nil
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("AssetInfo %s not found", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AssetDigest returns the digest of the file with the given name. It returns an
|
|
|
|
// error if the asset could not be found or the digest could not be loaded.
|
|
|
|
func AssetDigest(name string) ([sha256.Size]byte, error) {
|
|
|
|
canonicalName := strings.Replace(name, "\\", "/", -1)
|
|
|
|
if f, ok := _bindata[canonicalName]; ok {
|
|
|
|
a, err := f()
|
|
|
|
if err != nil {
|
|
|
|
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err)
|
|
|
|
}
|
|
|
|
return a.digest, nil
|
|
|
|
}
|
|
|
|
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Digests returns a map of all known files and their checksums.
|
|
|
|
func Digests() (map[string][sha256.Size]byte, error) {
|
|
|
|
mp := make(map[string][sha256.Size]byte, len(_bindata))
|
|
|
|
for name := range _bindata {
|
|
|
|
a, err := _bindata[name]()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
mp[name] = a.digest
|
|
|
|
}
|
|
|
|
return mp, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AssetNames returns the names of the assets.
|
|
|
|
func AssetNames() []string {
|
|
|
|
names := make([]string, 0, len(_bindata))
|
|
|
|
for name := range _bindata {
|
|
|
|
names = append(names, name)
|
|
|
|
}
|
|
|
|
return names
|
|
|
|
}
|
|
|
|
|
|
|
|
// _bindata is a table, holding each asset generator, mapped to its name.
|
|
|
|
var _bindata = map[string]func() (*asset, error){
|
2019-07-26 07:17:29 +00:00
|
|
|
"000001_init.down.db.sql": _000001_initDownDbSql,
|
2019-07-17 22:25:42 +00:00
|
|
|
|
2019-07-26 07:17:29 +00:00
|
|
|
"000001_init.up.db.sql": _000001_initUpDbSql,
|
2019-07-17 22:25:42 +00:00
|
|
|
|
|
|
|
"doc.go": docGo,
|
|
|
|
}
|
|
|
|
|
|
|
|
// AssetDir returns the file names below a certain
|
|
|
|
// directory embedded in the file by go-bindata.
|
|
|
|
// For example if you run go-bindata on data/... and data contains the
|
|
|
|
// following hierarchy:
|
|
|
|
// data/
|
|
|
|
// foo.txt
|
|
|
|
// img/
|
|
|
|
// a.png
|
|
|
|
// b.png
|
|
|
|
// then AssetDir("data") would return []string{"foo.txt", "img"},
|
|
|
|
// AssetDir("data/img") would return []string{"a.png", "b.png"},
|
|
|
|
// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and
|
|
|
|
// AssetDir("") will return []string{"data"}.
|
|
|
|
func AssetDir(name string) ([]string, error) {
|
|
|
|
node := _bintree
|
|
|
|
if len(name) != 0 {
|
|
|
|
canonicalName := strings.Replace(name, "\\", "/", -1)
|
|
|
|
pathList := strings.Split(canonicalName, "/")
|
|
|
|
for _, p := range pathList {
|
|
|
|
node = node.Children[p]
|
|
|
|
if node == nil {
|
|
|
|
return nil, fmt.Errorf("Asset %s not found", name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if node.Func != nil {
|
|
|
|
return nil, fmt.Errorf("Asset %s not found", name)
|
|
|
|
}
|
|
|
|
rv := make([]string, 0, len(node.Children))
|
|
|
|
for childName := range node.Children {
|
|
|
|
rv = append(rv, childName)
|
|
|
|
}
|
|
|
|
return rv, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type bintree struct {
|
|
|
|
Func func() (*asset, error)
|
|
|
|
Children map[string]*bintree
|
|
|
|
}
|
|
|
|
|
|
|
|
var _bintree = &bintree{nil, map[string]*bintree{
|
2020-01-10 18:59:01 +00:00
|
|
|
"000001_init.down.db.sql": &bintree{_000001_initDownDbSql, map[string]*bintree{}},
|
|
|
|
"000001_init.up.db.sql": &bintree{_000001_initUpDbSql, map[string]*bintree{}},
|
|
|
|
"doc.go": &bintree{docGo, map[string]*bintree{}},
|
2019-07-17 22:25:42 +00:00
|
|
|
}}
|
|
|
|
|
|
|
|
// RestoreAsset restores an asset under the given directory.
|
|
|
|
func RestoreAsset(dir, name string) error {
|
|
|
|
data, err := Asset(name)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
info, err := AssetInfo(name)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
|
|
|
}
|
|
|
|
|
|
|
|
// RestoreAssets restores an asset under the given directory recursively.
|
|
|
|
func RestoreAssets(dir, name string) error {
|
|
|
|
children, err := AssetDir(name)
|
|
|
|
// File
|
|
|
|
if err != nil {
|
|
|
|
return RestoreAsset(dir, name)
|
|
|
|
}
|
|
|
|
// Dir
|
|
|
|
for _, child := range children {
|
|
|
|
err = RestoreAssets(dir, filepath.Join(name, child))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func _filePath(dir, name string) string {
|
|
|
|
canonicalName := strings.Replace(name, "\\", "/", -1)
|
|
|
|
return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...)
|
|
|
|
}
|