Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 15, 2025

Problem

CSV export and import were not handling tags, causing tag data to be lost during backup and restore operations. This was reported in issue where users noted that tags were neither present in exports nor restored during imports.

Solution

This PR adds full tag support to both CSV export and import functionality by making minimal, surgical changes to the backup system.

Changes

Export Side:

  • Modified CsvWriter.kt to use ListDeeprWithTagsAsc instead of Deepr to include tag information
  • Updated ExportRepositoryImpl.kt to fetch data using listDeeprWithTagsAsc() query
  • Added "Tags" column to CSV header and output

Import Side:

  • Updated ImportRepositoryImpl.kt to parse tags from the CSV's 6th column
  • Added transaction-safe tag import logic that:
    • Creates tags if they don't exist (using INSERT OR IGNORE)
    • Links tags to imported links using existing database operations

Format:

  • Tags are exported/imported as comma-separated values: "tag1, tag2, tag3"
  • Matches the SQL GROUP_CONCAT(Tags.name, ', ') format used throughout the codebase
  • Consistent with the markdown sync feature's tag handling

Backward Compatibility

Old CSV files without the Tags column will continue to import successfully since:

  • The header validation only requires the first 3 columns (Link, CreatedAt, OpenedCount)
  • Tag parsing uses getOrNull(5) which safely returns null for missing columns
  • Empty/null tag values are handled gracefully as empty strings

Testing

The implementation was verified by:

  • Code review to ensure it matches existing patterns in SyncRepositoryImpl.kt
  • Validation that it uses existing database queries and maintains transaction integrity
  • Confirmation that the tag separator format matches the database query output

Fixes the issue where tags were not included in CSV export and backup.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/agents/gradle-instrumentation-agent-8.13.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.13 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>CSV import doesn't import tags</issue_title>
<issue_description>I think they are not even present in the export and backup</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #176


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: yogeshpaliyal <9381846+yogeshpaliyal@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Fix CSV import to include tags Fix CSV import/export to include tags Oct 15, 2025
@Copilot Copilot AI requested a review from yogeshpaliyal October 15, 2025 10:41
Copilot finished work on behalf of yogeshpaliyal October 15, 2025 10:41
@yogeshpaliyal yogeshpaliyal marked this pull request as ready for review October 18, 2025 08:46
@yogeshpaliyal yogeshpaliyal merged commit 631b331 into master Oct 18, 2025
1 check passed
@yogeshpaliyal yogeshpaliyal deleted the copilot/fix-csv-import-tags branch October 18, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants