Revert "make new changes backwards-compatible while we migrate"
This reverts commit 594a45a271
.
This commit is contained in:
parent
2497f354bd
commit
3e006f1571
1 changed files with 10 additions and 9 deletions
19
db/db.go
19
db/db.go
|
@ -96,10 +96,10 @@ func (s *SQL) insertBlob(hash string, length int, isStored bool) (int64, error)
|
|||
return blobID, nil
|
||||
}
|
||||
|
||||
func (s *SQL) insertStream(hash, sdHash string, sdBlobID int64) (int64, error) {
|
||||
func (s *SQL) insertStream(hash string, sdBlobID int64) (int64, error) {
|
||||
streamID, err := s.exec(
|
||||
"INSERT IGNORE INTO stream (hash, sd_hash, sd_blob_id) VALUES (?,?, ?)",
|
||||
hash, sdHash, sdBlobID,
|
||||
"INSERT IGNORE INTO stream (hash, sd_blob_id) VALUES (?,?)",
|
||||
hash, sdBlobID,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, errors.Err(err)
|
||||
|
@ -189,7 +189,7 @@ func (s *SQL) HasBlobs(hashes []string) (map[string]bool, error) {
|
|||
|
||||
// Delete will remove the blob from the db
|
||||
func (s *SQL) Delete(hash string) error {
|
||||
_, err := s.exec("DELETE FROM stream WHERE sd_hash = ?", hash)
|
||||
_, err := s.exec("DELETE FROM stream WHERE sd_blob_id = (SELECT id FROM blob_ WHERE hash = ?)", hash)
|
||||
if err != nil {
|
||||
return errors.Err(err)
|
||||
}
|
||||
|
@ -246,8 +246,9 @@ func (s *SQL) MissingBlobsForKnownStream(sdHash string) ([]string, error) {
|
|||
|
||||
query := `
|
||||
SELECT b.hash FROM blob_ b
|
||||
INNER JOIN stream_blob sb ON b.hash = sb.blob_hash
|
||||
INNER JOIN stream s ON s.hash = sb.stream_hash AND s.sd_hash = ?
|
||||
INNER JOIN stream_blob sb ON b.id = sb.blob_id
|
||||
INNER JOIN stream s ON s.id = sb.stream_id
|
||||
INNER JOIN blob_ sdb ON sdb.id = s.sd_blob_id AND sdb.hash = ?
|
||||
WHERE b.is_stored = 0
|
||||
`
|
||||
args := []interface{}{sdHash}
|
||||
|
@ -291,7 +292,7 @@ func (s *SQL) AddSDBlob(sdHash string, sdBlobLength int, sdBlob SdBlob) error {
|
|||
return err
|
||||
}
|
||||
|
||||
streamID, err := s.insertStream(sdBlob.StreamHash, sdHash, sdBlobID)
|
||||
streamID, err := s.insertStream(sdBlob.StreamHash, sdBlobID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -309,8 +310,8 @@ func (s *SQL) AddSDBlob(sdHash string, sdBlobLength int, sdBlob SdBlob) error {
|
|||
}
|
||||
|
||||
_, err = s.exec(
|
||||
"INSERT IGNORE INTO stream_blob (stream_id, stream_hash, blob_id, blob_hash, num) VALUES (?,?,?,?,?)",
|
||||
streamID, sdBlob.StreamHash, blobID, contentBlob.BlobHash, contentBlob.BlobNum,
|
||||
"INSERT IGNORE INTO stream_blob (stream_id, blob_id, num) VALUES (?,?,?)",
|
||||
streamID, blobID, contentBlob.BlobNum,
|
||||
)
|
||||
if err != nil {
|
||||
return errors.Err(err)
|
||||
|
|
Loading…
Reference in a new issue