fix(export): exclude application data from portable notes
This commit is contained in:
1 parent
9449a1aa65
commit
c705d1ab33
5 files changed
+159
-4
No files matched your search
@@ -20,7 +20,7 @@ func TestExportNotesKeepsMarkdownAndReportsMissingAssets(t *testing.T) {
|
||||
}
|
||||
v.Delete("other.md")
|
||||
v.SaveAsset("note.md", "a.png", strings.NewReader("image"), 50<<20)
|
||||
file, err := v.ExportNotes(context.Background())
|
||||
file, err := v.ExportNotes(context.Background(), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -58,3 +58,28 @@ func TestExportNotesKeepsMarkdownAndReportsMissingAssets(t *testing.T) {
|
||||
t.Fatalf("导出包不能导回: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExportNotesExcludesItsOwnOutputInsideVault(t *testing.T) {
|
||||
v := newVault(t)
|
||||
t.Setenv("TMPDIR", v.Root())
|
||||
if _, err := v.Write("note.md", []byte("source"), Precondition{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
file, err := v.ExportNotes(context.Background(), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(file.Name())
|
||||
defer file.Close()
|
||||
info, err := file.Stat()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
z, err := zip.NewReader(file, info.Size())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(z.File) != 1 || z.File[0].Name != "note.md" {
|
||||
t.Fatal("导出包含自身临时文件")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user