Skip to content

Commit

Permalink
fix: avoid file not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
suxb201 committed Dec 13, 2024
1 parent 9a45203 commit 0bb1ab7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RedisShake is a powerful tool for Redis data transformation and migration, offer
2. **Redis Compatibility**: Supports Redis 2.8 to 7.4, across standalone, master-slave, sentinel, and cluster deployments.

3. **Cloud Service Integration**: Seamlessly works with Redis-like databases from major cloud providers:
- Alibaba Cloud: [ApsaraDB for Redis](https://www.alibabacloud.com/product/apsaradb-for-redis), [Tair](https://www.alibabacloud.com/product/tair)
- Alibaba Cloud: [Tair (Redis® OSS-Compatible)](https://www.alibabacloud.com/en/product/tair)
- AWS: [ElastiCache](https://aws.amazon.com/elasticache/), [MemoryDB](https://aws.amazon.com/memorydb/)

4. **Module Support**: Compatible with [TairString](https://github.com/tair-opensource/TairString), [TairZSet](https://github.com/tair-opensource/TairZset), and [TairHash](https://github.com/tair-opensource/TairHash).
Expand Down
12 changes: 12 additions & 0 deletions internal/utils/file_rotate/aof_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"os"
"time"
)

type AOFReader struct {
Expand All @@ -21,7 +22,18 @@ func NewAOFReader(name string, dir string, offset int64) *AOFReader {
r := new(AOFReader)
r.name = name
r.dir = dir

filepath := fmt.Sprintf("%s/%d.aof", r.dir, r.offset)

startWaitTimeStart := time.Now()
for !utils.IsExist(filepath) {
time.Sleep(100 * time.Millisecond)
if time.Since(startWaitTimeStart) > 3*time.Second {
log.Panicf("[%s] file not exist. filename=[%s]", r.name, filepath)
}
}
r.openFile(offset)

return r
}

Expand Down

0 comments on commit 0bb1ab7

Please sign in to comment.