Commit d8062c33 authored by ale's avatar ale

provide some feedback during Sync()

parent 6c4960f5
......@@ -6,6 +6,7 @@ import (
"encoding/binary"
"encoding/gob"
"errors"
"fmt"
"log"
"math/rand"
"os"
......@@ -43,6 +44,10 @@ type Book struct {
Metadata *Metadata
}
func (b *Book) String() string {
return fmt.Sprintf("%s (%s)", b.Metadata.String(), b.Id.String())
}
type File struct {
Path string
FileType string
......
......@@ -147,11 +147,10 @@ func (m *Metadata) String() string {
if len(m.Creator) > 0 {
author = shortAuthorString(m.Creator)
}
year := "unknown year"
if m.Date != "" {
year = toYear(m.Date)
return fmt.Sprintf("%s, \"%s\", %s", author, m.Title, toYear(m.Date))
}
return fmt.Sprintf("%s, \"%s\", %s", author, m.Title, year)
return fmt.Sprintf("%s, \"%s\"", author, m.Title)
}
func parseEpub(filename string) (*Metadata, error) {
......
......@@ -232,6 +232,7 @@ func (db *Database) Sync(storage *FileStorage, remote SyncClient) error {
bookid := ParseID(id)
if book, err := db.GetBook(bookid); err == nil {
if files, err := db.GetBookFiles(bookid); err == nil {
log.Printf("uploading %s", book.String())
if err := remote.SendBook(book, storage, files); err != nil {
log.Printf("SendBook(%s): %v", id, err)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment