Skip to content

Commit 81776e5

Browse files
author
openset
committed
Add: reserved content
1 parent 65eac1d commit 81776e5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: internal/leetcode/question_data.go

+12
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ func QuestionData(titleSlug string, isForce bool, graphQL ...string) (qd questio
2828
graphQL = []string{graphQLCnUrl}
2929
}
3030
filename := fmt.Sprintf(questionDataFile, slugToSnake(titleSlug))
31+
oldContent := getContent(filename)
3132
graphQLRequest(graphQL[0], jsonStr, filename, days, &qd)
33+
if qd.Data.Question.Content == "" && oldContent != "" {
34+
qd.Data.Question.Content = oldContent
35+
filePutContents(filename, jsonEncode(qd))
36+
}
3237
if qd.Data.Question.TitleSlug == "" {
3338
_ = os.Remove(getCachePath(filename))
3439
if graphQL[0] == graphQLCnUrl {
@@ -286,6 +291,13 @@ func filterContents(cts string) string {
286291
return cts
287292
}
288293

294+
func getContent(filename string) string {
295+
var qd questionDataType
296+
cts := fileGetContents(filename)
297+
jsonDecode(cts, &qd)
298+
return qd.Data.Question.Content
299+
}
300+
289301
const testTpl = `package {{packageName}}
290302
291303
import "testing"

0 commit comments

Comments
 (0)