mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-06 10:05:58 +08:00
feat: url to im s3 (#1067)
* fix: repeated modification session notification * fix: repeated modification session notification * fix: jpush return a nil pointer panic * fix: push redis pkg * fix: OANotification * feat: add rpc GetConversationNeedOfflinePushUserIDs * update pkg * cicd: robot automated Change * offlinePushMsg * conversation * conversation * cicd: robot automated Change * conversation * cicd: robot automated Change * conversation * url 2 im s3 * url 2 im s3 * cicd: robot automated Change * url 2 im s3 --------- Co-authored-by: withchao <withchao@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package pkg
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/kelindar/bitmap"
|
||||
)
|
||||
|
||||
func ReadProgress(path string) (*Progress, error) {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return &Progress{}, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
scanner := bufio.NewScanner(file)
|
||||
var upload bitmap.Bitmap
|
||||
for scanner.Scan() {
|
||||
index, err := strconv.Atoi(scanner.Text())
|
||||
if err != nil || index < 0 {
|
||||
continue
|
||||
}
|
||||
upload.Set(uint32(index))
|
||||
}
|
||||
return &Progress{upload: upload}, nil
|
||||
}
|
||||
|
||||
type Progress struct {
|
||||
upload bitmap.Bitmap
|
||||
}
|
||||
|
||||
func (p *Progress) IsUploaded(index int) bool {
|
||||
if p == nil {
|
||||
return false
|
||||
}
|
||||
return p.upload.Contains(uint32(index))
|
||||
}
|
||||
Reference in New Issue
Block a user