mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-30 05:56:54 -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)
|
||||
fsifce := fsenvironment.(filesystemcap.FileSystemCapabilitySet)
|
||||
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)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
file.Close()
|
||||
field := message.Descriptor().Fields().ByTextName(v.field)
|
||||
message.Set(field, protoreflect.ValueOf(fileContent))
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user