diff --git a/internal/leetcode/question_data.go b/internal/leetcode/question_data.go index 56523887f..db52de55e 100644 --- a/internal/leetcode/question_data.go +++ b/internal/leetcode/question_data.go @@ -28,7 +28,12 @@ func QuestionData(titleSlug string, isForce bool, graphQL ...string) (qd questio graphQL = []string{graphQLCnUrl} } filename := fmt.Sprintf(questionDataFile, slugToSnake(titleSlug)) + oldContent := getContent(filename) graphQLRequest(graphQL[0], jsonStr, filename, days, &qd) + if qd.Data.Question.Content == "" && oldContent != "" { + qd.Data.Question.Content = oldContent + filePutContents(filename, jsonEncode(qd)) + } if qd.Data.Question.TitleSlug == "" { _ = os.Remove(getCachePath(filename)) if graphQL[0] == graphQLCnUrl { @@ -286,6 +291,13 @@ func filterContents(cts string) string { return cts } +func getContent(filename string) string { + var qd questionDataType + cts := fileGetContents(filename) + jsonDecode(cts, &qd) + return qd.Data.Question.Content +} + const testTpl = `package {{packageName}} import "testing"