Cloudbox / autoscan

Autoscan replaces the default Plex and Emby behaviour for picking up changes on the file system.
MIT License
594 stars 49 forks source link

feat(triggers/targets): Add slash direction support #186

Open Alanoll opened 1 year ago

Alanoll commented 1 year ago

I saw issue #178 and the comment by @m-rots , and thought I'd try my hand at Go (still a novice at it).

Instead of putting the slashDirection option in the Rewrite configurations, I thought (possibly naively) that it'd make more sense in the individual trigger/targets themselves. My thinking was that each instance of the services won't change it's slash preference, but separate instances could.

The idea being Autoscan wants everything internally to itself to be forward slashes, so:

The possibly confusing part is that the replacements occur before and after the rewrite rules process. So from the example issue:

 rewrite:
  - from: /partage/
    to: \\dn\partage\
  - from: /partaget/
    to: \\dn\partaget\

would instead be: rewrite:

  • from: /partage/ to: //dn/partage/
  • from: /partaget/ to: //dn/partaget/ Since all slashes when rewriting are forward. Should also avoid any RegEx expression escaping issues with the backward slashes.

I saw the comment about enumeration, don't really know how to make one in Go, and then have the Yaml serializer convert it, so I left everything as strings.

Alanoll commented 1 year ago

@l3uddz Is this something we can get merged?

aleksasiriski commented 1 year ago

@l3uddz Is this something we can get merged?

@Alanoll Are you willing to make this PR here?

aleksasiriski commented 1 year ago

This can be closed, since it's added to my fork (which also has an open PR)