Skip to content

Commit

Permalink
bug fixes in mysql adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Jun 21, 2018
1 parent 1386771 commit 8cb8a50
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions server/db/mysql/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ func (a *adapter) CreateDb(reset bool) error {
location VARCHAR(2048) NOT NULL,
PRIMARY KEY(id),
FOREIGN KEY(userid) REFERENCES users(id),
FOREIGN KEY(topic) REFERENCES topics(name),
INDEX fileuploads_topic_seqid (topic, seqid),
INDEX fileuploads_usecount(usecount)
)`); err != nil {
Expand Down Expand Up @@ -1741,8 +1740,8 @@ func (a *adapter) CredGet(uid t.Uid, method string) ([]*t.Credential, error) {

// FileStartUpload initializes a file upload
func (a *adapter) FileStartUpload(fd *t.FileDef) error {
_, err := a.db.Exec("INSERT INTO fileuploads(id,createdat,updatedat,userid,status,mimetype,size,location)"+
" VALUES(?,?,?,?,?,?,?,?)",
_, err := a.db.Exec("INSERT INTO fileuploads(id,createdat,updatedat,userid,topic,seqid,status,mimetype,size,location)"+
" VALUES(?,?,?,?,?,?,?,?,?,?)",
store.DecodeUid(fd.Uid()), fd.CreatedAt, fd.UpdatedAt,
store.DecodeUid(t.ParseUid(fd.User)), fd.Topic, fd.SeqId, fd.Status, fd.MimeType, fd.Size, fd.Location)
return err
Expand Down
3 changes: 1 addition & 2 deletions server/db/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ CREATE TABLE fileuploads(
createdat DATETIME(3) NOT NULL,
updatedat DATETIME(3) NOT NULL,
userid BIGINT NOT NULL,
seqid INT,
topic CHAR(25) NOT NULL,
seqid INT,
status INT NOT NULL,
mimetype VARCHAR(255) NOT NULL,
size BIGINT NOT NULL,
Expand All @@ -194,7 +194,6 @@ CREATE TABLE fileuploads(

PRIMARY KEY(id),
FOREIGN KEY(userid) REFERENCES users(id),
FOREIGN KEY(topic) REFERENCES topics(name),
# This index should not be unique: one message may have multiple attachments.
INDEX fileuploads_topic_seqid (topic, seqid),
INDEX fileuploads_usecount(usecount)
Expand Down
2 changes: 1 addition & 1 deletion server/media/fs/filesys.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (fh *fshandler) Upload(fdef *types.FileDef, file io.Reader) (string, error)
if err = store.Files.StartUpload(fdef); err != nil {
outfile.Close()
os.Remove(fdef.Location)
log.Println("U: failed to create file record", fdef.Id, err)
log.Println("Upload: failed to create file record", fdef.Id, err)
return "", err
}

Expand Down

0 comments on commit 8cb8a50

Please sign in to comment.