expo-tiddlywiki-filesystem-android-external-storage 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -590,6 +590,8 @@ class ExternalStorageModule : Module() {
|
|
|
590
590
|
val changes = JSONArray()
|
|
591
591
|
val indexPaths = mutableSetOf<String>()
|
|
592
592
|
|
|
593
|
+
var modifiedCount = 0
|
|
594
|
+
var deletedCount = 0
|
|
593
595
|
for (entry in indexEntries) {
|
|
594
596
|
indexPaths.add(entry.path)
|
|
595
597
|
val workFile = File(root, entry.path)
|
|
@@ -599,6 +601,7 @@ class ExternalStorageModule : Module() {
|
|
|
599
601
|
obj.put("path", entry.path)
|
|
600
602
|
obj.put("type", "delete")
|
|
601
603
|
changes.put(obj)
|
|
604
|
+
deletedCount++
|
|
602
605
|
} else {
|
|
603
606
|
// Check stat cache: size and mtime
|
|
604
607
|
val diskSize = workFile.length()
|
|
@@ -608,23 +611,119 @@ class ExternalStorageModule : Module() {
|
|
|
608
611
|
obj.put("path", entry.path)
|
|
609
612
|
obj.put("type", "modify")
|
|
610
613
|
changes.put(obj)
|
|
614
|
+
modifiedCount++
|
|
615
|
+
if (modifiedCount <= 3) {
|
|
616
|
+
android.util.Log.i("GitStatus", " modify: ${entry.path} disk(size=$diskSize,mtime=$diskMtime) vs index(size=${entry.size},mtime=${entry.mtimeSeconds})")
|
|
617
|
+
}
|
|
611
618
|
}
|
|
612
619
|
}
|
|
613
620
|
}
|
|
614
621
|
|
|
615
622
|
// 4. Files on disk but not in index → added
|
|
623
|
+
var addedCount = 0
|
|
616
624
|
for (path in workdirFiles) {
|
|
617
625
|
if (path !in indexPaths) {
|
|
618
626
|
val obj = JSONObject()
|
|
619
627
|
obj.put("path", path)
|
|
620
628
|
obj.put("type", "add")
|
|
621
629
|
changes.put(obj)
|
|
630
|
+
addedCount++
|
|
631
|
+
if (addedCount <= 5) {
|
|
632
|
+
android.util.Log.i("GitStatus", " add: $path")
|
|
633
|
+
}
|
|
622
634
|
}
|
|
623
635
|
}
|
|
624
636
|
|
|
637
|
+
android.util.Log.i("GitStatus", "Result: ${changes.length()} changes (add=$addedCount, modify=$modifiedCount, delete=$deletedCount), indexEntries=${indexEntries.size}, workdirFiles=${workdirFiles.size}")
|
|
625
638
|
changes.toString()
|
|
626
639
|
}
|
|
627
640
|
|
|
641
|
+
/**
|
|
642
|
+
* Return diagnostic info about git index vs working directory.
|
|
643
|
+
* Used to debug why gitStatus returns 0 when changes exist.
|
|
644
|
+
*/
|
|
645
|
+
AsyncFunction("gitStatusDebug") { gitRootDir: String ->
|
|
646
|
+
val root = File(gitRootDir)
|
|
647
|
+
val gitDir = File(root, ".git")
|
|
648
|
+
val indexFile = File(gitDir, "index")
|
|
649
|
+
|
|
650
|
+
val result = JSONObject()
|
|
651
|
+
|
|
652
|
+
if (!indexFile.exists()) {
|
|
653
|
+
result.put("error", "no git index file")
|
|
654
|
+
return@AsyncFunction result.toString()
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
val indexEntries = parseGitIndex(indexFile)
|
|
658
|
+
result.put("indexEntryCount", indexEntries.size)
|
|
659
|
+
|
|
660
|
+
// Sample a few index entries with their stats
|
|
661
|
+
val indexSamples = JSONArray()
|
|
662
|
+
// Find $__StoryList.tid or similar common tiddler in the index
|
|
663
|
+
val storyListEntry = indexEntries.find { it.path == "tiddlers/\$__StoryList.tid" }
|
|
664
|
+
if (storyListEntry != null) {
|
|
665
|
+
val obj = JSONObject()
|
|
666
|
+
obj.put("path", storyListEntry.path)
|
|
667
|
+
obj.put("indexSize", storyListEntry.size)
|
|
668
|
+
obj.put("indexMtime", storyListEntry.mtimeSeconds)
|
|
669
|
+
val workFile = File(root, storyListEntry.path)
|
|
670
|
+
obj.put("diskExists", workFile.exists())
|
|
671
|
+
if (workFile.exists()) {
|
|
672
|
+
obj.put("diskSize", workFile.length())
|
|
673
|
+
obj.put("diskMtime", workFile.lastModified() / 1000)
|
|
674
|
+
obj.put("diskMtimeMs", workFile.lastModified())
|
|
675
|
+
obj.put("sizeMatch", workFile.length() == storyListEntry.size)
|
|
676
|
+
obj.put("mtimeMatch", workFile.lastModified() / 1000 == storyListEntry.mtimeSeconds)
|
|
677
|
+
}
|
|
678
|
+
indexSamples.put(obj)
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// Check 新条目.tid
|
|
682
|
+
val newEntryFile = File(root, "tiddlers/新条目.tid")
|
|
683
|
+
val newObj = JSONObject()
|
|
684
|
+
newObj.put("path", "tiddlers/新条目.tid")
|
|
685
|
+
newObj.put("diskExists", newEntryFile.exists())
|
|
686
|
+
if (newEntryFile.exists()) {
|
|
687
|
+
newObj.put("diskSize", newEntryFile.length())
|
|
688
|
+
newObj.put("diskMtime", newEntryFile.lastModified() / 1000)
|
|
689
|
+
}
|
|
690
|
+
val inIndex = indexEntries.any { it.path == "tiddlers/新条目.tid" }
|
|
691
|
+
newObj.put("inIndex", inIndex)
|
|
692
|
+
indexSamples.put(newObj)
|
|
693
|
+
|
|
694
|
+
// Walk working dir and count
|
|
695
|
+
val skipDirs = setOf(".git", "node_modules", "output")
|
|
696
|
+
val workdirFiles = mutableSetOf<String>()
|
|
697
|
+
fun walkDir(dir: File, prefix: String) {
|
|
698
|
+
val children = dir.listFiles() ?: return
|
|
699
|
+
for (child in children) {
|
|
700
|
+
val relPath = if (prefix.isEmpty()) child.name else "$prefix/${child.name}"
|
|
701
|
+
if (child.isDirectory) {
|
|
702
|
+
if (child.name !in skipDirs) walkDir(child, relPath)
|
|
703
|
+
} else {
|
|
704
|
+
workdirFiles.add(relPath)
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
walkDir(root, "")
|
|
709
|
+
|
|
710
|
+
result.put("workdirFileCount", workdirFiles.size)
|
|
711
|
+
result.put("tiddlerFileCount", workdirFiles.count { it.startsWith("tiddlers/") })
|
|
712
|
+
result.put("newEntryInWorkdir", workdirFiles.contains("tiddlers/新条目.tid"))
|
|
713
|
+
result.put("samples", indexSamples)
|
|
714
|
+
|
|
715
|
+
// Count files in workdir not in index (potential adds)
|
|
716
|
+
val indexPaths = indexEntries.map { it.path }.toSet()
|
|
717
|
+
val addCount = workdirFiles.count { it !in indexPaths }
|
|
718
|
+
result.put("potentialAddCount", addCount)
|
|
719
|
+
// List first 5 potential adds
|
|
720
|
+
val addSamples = JSONArray()
|
|
721
|
+
workdirFiles.filter { it !in indexPaths }.take(5).forEach { addSamples.put(it) }
|
|
722
|
+
result.put("potentialAddSamples", addSamples)
|
|
723
|
+
|
|
724
|
+
result.toString()
|
|
725
|
+
}
|
|
726
|
+
|
|
628
727
|
// ─── TiddlyWiki batch file parsing ─────────────────────────────────
|
|
629
728
|
|
|
630
729
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-tiddlywiki-filesystem-android-external-storage",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Expo native module for TidGi-Mobile: external storage I/O + TiddlyWiki .tid/.meta/.json batch parsing in Kotlin",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|