fix: avoid file not exist
This commit is contained in:
parent
9a452036c5
commit
0bb1ab7246
|
@ -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).
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AOFReader struct {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue