How to remove file from the library?

Is there a way to remove file completely from the library from CLI? Or the only way is to remove the database row from the Asset table?

1 Like

Not until Deleting / hiding photos is built.

The issues is if I delete the asset or asset file from the database, the next sync will just reimport the file.

The next build adds a shaBlocklist to make sure deleted or excluded assets stay that way.

I hadn’t thought of adding cli support for delete: thanks for the idea!

1 Like

No, the file won’t be reimported if I remove it physically. That’s the problem as I see, that your sync only adds and never removes

The last phase of a sync is supposed to detect previously imported files that were deleted, and remove the asset file. Any orphaned assets are then supposed to be deleted.

This was added fairly recently, in v0.9.

What platform and version are you seeing this?

$ ./photostructure --version
1.0.0-alpha.3

$ ls F:/SynologyDrive/Photos/test.jpg
ls: cannot access 'F:/SynologyDrive/Photos/test.jpg': No such file or directory

$ ./photostructure sync --exit-when-done

$ ./photostructure list --where "AssetFile.uri like '%test%'"
F:\SynologyDrive\Photos\test.jpg

So file was physically removed but not removed from the AssetFile

Moreover, for whatever reason, new files were not added as well after the sync

$ ./photostructure list --where "AssetFile.uri like '%20177%'"
(nothing)

$ ls F:/SynologyDrive/Photos/0021/20177.JPG
F:/SynologyDrive/Photos/0021/20177.JPG

settings.toml file has setting

scanPaths = [
  "F:\\SynologyDrive\\Photos"
]

Did this actually run? I suspect it short-circuited because it’d been less than a day since the last sync. You can tell what it’s up to by adding the --info arg.

Normally when you start sync it only starts a sync for your scanned paths that have not been synced for syncIntervalHours (which defaults to 24).

You can run sync with --force to ignore the last-synced time, and force it to run, or use PS_SYNC_INTERVAL_HOURS=1.

You can also include a specific folder to sync as an argument, so you could give it a smaller test subdirectory. The folder doesn’t need to be in your scanned paths, but know that PhotoStructure won’t automatically add that folder to scanPaths, and therefore won’t schedule syncs that folder in the future.

I can’t tell anymore. I decided to drop the entire database and build it from scratch. But I will keep eye on the issue once my db is rebuilt