diff --git a/README.md b/README.md index 43c2f8ce5..58c616f76 100644 --- a/README.md +++ b/README.md @@ -196,11 +196,9 @@ In addition, you can also consider manually exporting and importing data to achi SiYuan is completely open source, and contributions are welcome: * [User Interface and Kernel](https://github.com/siyuan-note/siyuan) -* [User Guide](https://github.com/siyuan-note/user-guide-en_US) and [Appearance](https://github.com/siyuan-note/appearance) -* [Editor Engine](https://github.com/88250/lute) -* [End-to-end encryption](https://github.com/siyuan-note/encryption) and [Data repo](https://github.com/siyuan-note/dejavu) +* [Android](https://github.com/siyuan-note/siyuan-android) +* [iOS](https://github.com/siyuan-note/siyuan-ios) * [Chrome Clipping Extension](https://github.com/siyuan-note/siyuan-chrome) -* [Android](https://github.com/siyuan-note/siyuan-android) and [iOS](https://github.com/siyuan-note/siyuan-ios) For more details, please refer to [Development Guide](https://github.com/siyuan-note/siyuan/blob/master/.github/CONTRIBUTING.md). @@ -242,10 +240,6 @@ Ambiguity may occur when using Markdown markers to insert, please refer to [here The first sub-block under the list item is the block icon omitted. You can move the cursor into this block and trigger its block menu with Ctrl+/ . -### Why can't some online pictures be viewed? - -In order to avoid some potential security problems, SiYuan will not bypass the security header verification (such as security policy header and anti-leech verification) of the target site when initiating Internet service requests. You can try the `Convert network images to local images` function in the `...` in the upper right corner of the editor to pull the network image to the local, so that even if the target site changes the security policy or the local image is unavailable later, it will not be affected. - ### How to share notes? * Export and import `.sy.zip` package diff --git a/app/guide/20210808180117-6v0mkxr/20200923234731-h3zkwm2.sy b/app/guide/20210808180117-6v0mkxr/20200923234731-h3zkwm2.sy index b92b238c3..aea1e3010 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234731-h3zkwm2.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234731-h3zkwm2.sy @@ -1463,53 +1463,6 @@ } ] }, - { - "ID": "20220711123529-bjd0rvv", - "Type": "NodeHeading", - "HeadingLevel": 2, - "Properties": { - "id": "20220711123529-bjd0rvv", - "updated": "20220711123529" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "Why can't some online pictures be viewed?" - } - ] - }, - { - "ID": "20220711123529-xgrcde0", - "Type": "NodeParagraph", - "Properties": { - "id": "20220711123529-xgrcde0", - "updated": "20220711123705" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "In order to avoid some potential security problems, SiYuan will not bypass the security header verification (such as security policy header and anti-leech verification) of the target site when initiating Internet service requests. You can try the " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "Convert network images to local images" - }, - { - "Type": "NodeText", - "Data": " function in the " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "..." - }, - { - "Type": "NodeText", - "Data": " in the upper right corner of the editor to pull the network image to the local, so that even if the target site changes the security policy or the local image is unavailable later, it will not be affected." - } - ] - }, { "ID": "20220615153446-i8gpnt2", "Type": "NodeHeading", diff --git a/app/guide/20211226090932-5lcq56f/20211226115227-r1rty9v.sy b/app/guide/20211226090932-5lcq56f/20211226115227-r1rty9v.sy index 2d85d0b6b..1e9477b13 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115227-r1rty9v.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115227-r1rty9v.sy @@ -1453,53 +1453,6 @@ } ] }, - { - "ID": "20220711123511-bzzrzif", - "Type": "NodeHeading", - "HeadingLevel": 2, - "Properties": { - "id": "20220711123511-bzzrzif", - "updated": "20220711123511" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "有的網絡圖片為什麼無法查看?" - } - ] - }, - { - "ID": "20220711123511-7kicy5w", - "Type": "NodeParagraph", - "Properties": { - "id": "20220711123511-7kicy5w", - "updated": "20220711123511" - }, - "Children": [ - { - "Type": "NodeText", - "Data": "為了避免一些潛在的安全問題,思源在發起互聯網服務請求時不會繞過目標站點的安全標頭校驗(比如安全策略標頭和防盜鏈校驗)。可以試一下編輯器右上角 " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "..." - }, - { - "Type": "NodeText", - "Data": " 中的 " - }, - { - "Type": "NodeTextMark", - "TextMarkType": "code", - "TextMarkTextContent": "網絡圖片轉換為本地圖片" - }, - { - "Type": "NodeText", - "Data": " 功能將網絡圖片拉取到本地,這樣即使以後目標站點改變安全策略或者不可用本地圖片也不受影響。" - } - ] - }, { "ID": "20220615153430-zg69bjz", "Type": "NodeHeading", diff --git a/kernel/api/export.go b/kernel/api/export.go index f79044500..73c0d1e64 100644 --- a/kernel/api/export.go +++ b/kernel/api/export.go @@ -57,7 +57,13 @@ func exportData(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) - zipPath := model.ExportData() + zipPath, err := model.ExportData() + if nil != err { + ret.Code = 1 + ret.Msg = err.Error() + ret.Data = map[string]interface{}{"closeTimeout": 7000} + return + } ret.Data = map[string]interface{}{ "zip": zipPath, } diff --git a/kernel/go.mod b/kernel/go.mod index bc862b5a3..5f94ef0d6 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -26,7 +26,7 @@ require ( github.com/getsentry/sentry-go v0.16.0 github.com/gin-contrib/gzip v0.0.6 github.com/gin-contrib/sessions v0.0.5 - github.com/gin-gonic/gin v1.8.1 + github.com/gin-gonic/gin v1.8.2 github.com/gofrs/flock v0.8.1 github.com/imroc/req/v3 v3.26.5 github.com/jinzhu/copier v0.3.5 @@ -39,7 +39,7 @@ require ( github.com/patrickmn/go-cache v2.1.0+incompatible github.com/radovskyb/watcher v1.0.7 github.com/shirou/gopsutil/v3 v3.22.11 - github.com/siyuan-note/dejavu v0.0.0-20221229164238-fe7ae8875bba + github.com/siyuan-note/dejavu v0.0.0-20221231091617-c76bbed8303e github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e @@ -50,7 +50,7 @@ require ( github.com/studio-b12/gowebdav v0.0.0-20221109171924-60ec5ad56012 github.com/vmihailenco/msgpack/v5 v5.3.5 github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 - golang.org/x/image v0.1.0 + golang.org/x/image v0.2.0 golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105 golang.org/x/text v0.5.0 ) @@ -62,7 +62,7 @@ require ( github.com/alecthomas/chroma v0.10.0 // indirect github.com/andybalholm/cascadia v1.3.1 // indirect github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef // indirect - github.com/aws/aws-sdk-go v1.44.169 // indirect + github.com/aws/aws-sdk-go v1.44.171 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dsnet/compress v0.0.1 // indirect @@ -100,7 +100,7 @@ require ( github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect github.com/marten-seemann/qtls-go1-18 v0.1.4 // indirect github.com/marten-seemann/qtls-go1-19 v0.1.2 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -115,13 +115,13 @@ require ( github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect - github.com/ugorji/go/codec v1.2.7 // indirect + github.com/ugorji/go/codec v1.2.8 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect golang.org/x/crypto v0.4.0 // indirect - golang.org/x/exp v0.0.0-20221227203929-1b447090c38c // indirect + golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 // indirect golang.org/x/mod v0.7.0 // indirect golang.org/x/net v0.4.0 // indirect golang.org/x/sync v0.1.0 // indirect diff --git a/kernel/go.sum b/kernel/go.sum index 5b2524636..7a0178a14 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -50,6 +50,8 @@ github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef h1:2JGTg6JapxP github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef/go.mod h1:JS7hed4L1fj0hXcyEejnW57/7LCetXggd+vwrRnYeII= github.com/aws/aws-sdk-go v1.44.169 h1:+UAazxZwfcuCVtJ6LVR1hX+EJW6BPsFFAZERhOtFNrM= github.com/aws/aws-sdk-go v1.44.169/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.171 h1:maREiPAmibvuONMOEZIkCH2OTosLRnDelceTtH3SYfo= +github.com/aws/aws-sdk-go v1.44.171/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= @@ -106,6 +108,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY= +github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= @@ -266,6 +270,8 @@ github.com/marten-seemann/qtls-go1-19 v0.1.2/go.mod h1:5HTDWtVudo/WFsHKRNuOhWlbd github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= @@ -377,6 +383,8 @@ github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYED github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= github.com/siyuan-note/dejavu v0.0.0-20221229164238-fe7ae8875bba h1:7FFfsCj5uFLs+srDm/UNLsXqMt67urxSTHM6ZTw89QI= github.com/siyuan-note/dejavu v0.0.0-20221229164238-fe7ae8875bba/go.mod h1:/PrfKws59PtqGbA0I7IZ7a2E7wZsaUDbLBgLVSd47xo= +github.com/siyuan-note/dejavu v0.0.0-20221231091617-c76bbed8303e h1:M72lBvTRBO8tbFyEzPSubau0QP72lp+SFjEVw5zFWf4= +github.com/siyuan-note/dejavu v0.0.0-20221231091617-c76bbed8303e/go.mod h1:gTazhE8f5TuknSodwQukv7GHy+qR1crX5SCxARrTXZU= github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE= github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw= github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90= @@ -421,6 +429,8 @@ github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0= +github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= @@ -462,12 +472,16 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= golang.org/x/exp v0.0.0-20221227203929-1b447090c38c h1:Govq2W3bnHJimHT2ium65kXcI7ZzTniZHcFATnLJM0Q= golang.org/x/exp v0.0.0-20221227203929-1b447090c38c/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 h1:m9O6OTJ627iFnN2JIWfdqlZCzneRO6EEBsHXI25P8ws= +golang.org/x/exp v0.0.0-20221230185412-738e83a70c30/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20190823064033-3a9bac650e44/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.1.0 h1:r8Oj8ZA2Xy12/b5KZYj3tuv7NG/fBz3TwQVvpJ9l8Rk= golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c= +golang.org/x/image v0.2.0 h1:/DcQ0w3VHKCC5p0/P2B0JpAZ9Z++V2KOo2fyU89CXBQ= +golang.org/x/image v0.2.0/go.mod h1:la7oBXb9w3YFjBqaAwtynVioc1ZvOnNteUNrifGNmAI= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= diff --git a/kernel/model/export.go b/kernel/model/export.go index 72cbe3c08..abed74631 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -125,25 +125,30 @@ func ExportDataInFolder(exportFolder string) (name string, err error) { util.PushEndlessProgress(Conf.Language(65)) defer util.ClearPushProgress(100) - WaitForWritingFiles() - - exportFolder = filepath.Join(exportFolder, util.CurrentTimeSecondsStr()) - zipPath, err := exportData(exportFolder) + zipPath, err := ExportData() if nil != err { return } name = filepath.Base(zipPath) + targetZipPath := filepath.Join(exportFolder, name) + zipAbsPath := filepath.Join(util.TempDir, "export", name) + err = filelock.RoboCopy(zipAbsPath, targetZipPath) + if nil != err { + logging.LogErrorf("copy export zip from [%s] to [%s] failed: %s", zipAbsPath, targetZipPath, err) + return + } + if removeErr := os.Remove(zipAbsPath); nil != removeErr { + logging.LogErrorf("remove export zip failed: %s", removeErr) + } return } -func ExportData() (zipPath string) { +func ExportData() (zipPath string, err error) { util.PushEndlessProgress(Conf.Language(65)) defer util.ClearPushProgress(100) - WaitForWritingFiles() - exportFolder := filepath.Join(util.TempDir, "export", util.CurrentTimeSecondsStr()) - zipPath, err := exportData(exportFolder) + zipPath, err = exportData(exportFolder) if nil != err { return } @@ -152,6 +157,8 @@ func ExportData() (zipPath string) { } func exportData(exportFolder string) (zipPath string, err error) { + WaitForWritingFiles() + baseFolderName := "data-" + util.CurrentTimeSecondsStr() if err = os.MkdirAll(exportFolder, 0755); nil != err { logging.LogErrorf("create export temp folder failed: %s", err) diff --git a/kernel/util/file.go b/kernel/util/file.go index 060211872..f6ca0ae0b 100644 --- a/kernel/util/file.go +++ b/kernel/util/file.go @@ -240,7 +240,7 @@ func CeilSize(size int64) int64 { for i := int64(1); i < 40; i++ { if 1024*1024*200*i > size { - return 1024 * 1024 * int64(i) + return 1024 * 1024 * 200 * i } } return 1024*1024*200*40 + 1