mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 07:26:24 -05:00
skip file content reading if unnecessary
This commit is contained in:
parent
ef738cce7a
commit
a8c58c9ad4
@ -64,6 +64,15 @@ func filterMessage(ctx context.Context, message protoreflect.Message) error {
|
|||||||
fsenvironment := envctx.EnvironmentFromContext(ctx)
|
fsenvironment := envctx.EnvironmentFromContext(ctx)
|
||||||
fsifce := fsenvironment.(filesystemcap.FileSystemCapabilitySet)
|
fsifce := fsenvironment.(filesystemcap.FileSystemCapabilitySet)
|
||||||
for _, v := range fileReadingQueue {
|
for _, v := range fileReadingQueue {
|
||||||
|
field := message.Descriptor().Fields().ByTextName(v.field)
|
||||||
|
if v.filename == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(message.Get(field).Bytes()) > 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
file, err := fsifce.OpenFileForRead()(v.filename)
|
file, err := fsifce.OpenFileForRead()(v.filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return newError("unable to open file").Base(err)
|
return newError("unable to open file").Base(err)
|
||||||
@ -73,7 +82,6 @@ func filterMessage(ctx context.Context, message protoreflect.Message) error {
|
|||||||
return newError("unable to read file").Base(err)
|
return newError("unable to read file").Base(err)
|
||||||
}
|
}
|
||||||
file.Close()
|
file.Close()
|
||||||
field := message.Descriptor().Fields().ByTextName(v.field)
|
|
||||||
message.Set(field, protoreflect.ValueOf(fileContent))
|
message.Set(field, protoreflect.ValueOf(fileContent))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user