Skip to content

Commit

Permalink
Rename flatLinking and linkingCategory options (#656)
Browse files Browse the repository at this point in the history
This PR renames the `dataCategory` option to `linkingCategory`, renames
the `legacyLinking` option to `flatLinking`, and updates a couple
surrounding things (changing the default value of linkingCategory to
`cross-seed-link` instead of `cross-seed-data` and some small copy
updates.
  • Loading branch information
mmgoodnow committed Apr 23, 2024
1 parent e71c211 commit 467e087
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ async function linkAllFilesInMetafile(
| "UNKNOWN_ERROR"
>
> {
const { linkDir, legacyLinking } = getRuntimeConfig();
const fullLinkDir = legacyLinking ? linkDir : join(linkDir, tracker);
const { linkDir, flatLinking } = getRuntimeConfig();
const fullLinkDir = flatLinking ? linkDir : join(linkDir, tracker);
let sourceRoot: string;
if (searchee.path) {
sourceRoot = searchee.path;
Expand Down
6 changes: 3 additions & 3 deletions src/clients/Deluge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,17 @@ export default class Deluge implements TorrentClient {
params,
);
if (addResult.result) {
const { dataCategory } = getRuntimeConfig();
const { linkingCategory } = getRuntimeConfig();
await this.setLabel(
newTorrent.name,
newTorrent.infoHash,
searchee.path
? dataCategory
? linkingCategory
: torrentInfo!.label
? duplicateCategories
? torrentInfo!.label.endsWith(
this.delugeLabelSuffix,
) || torrentInfo!.label === dataCategory
) || torrentInfo!.label === linkingCategory
? torrentInfo!.label
: `${torrentInfo!.label}${
this.delugeLabelSuffix
Expand Down
8 changes: 4 additions & 4 deletions src/clients/QBittorrent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ export default class QBittorrent implements TorrentClient {
}

async setUpCrossSeedCategory(ogCategoryName: string): Promise<string> {
const { dataCategory } = getRuntimeConfig();
const { linkingCategory } = getRuntimeConfig();
if (!ogCategoryName) return "";
if (
ogCategoryName.endsWith(TORRENT_CATEGORY_SUFFIX) ||
ogCategoryName === dataCategory
ogCategoryName === linkingCategory
)
return ogCategoryName;

Expand Down Expand Up @@ -296,7 +296,7 @@ export default class QBittorrent implements TorrentClient {
| Decision.MATCH_PARTIAL,
path?: string,
): Promise<InjectionResult> {
const { duplicateCategories, skipRecheck, dataCategory } =
const { duplicateCategories, skipRecheck, linkingCategory } =
getRuntimeConfig();
try {
if (await this.isInfoHashInClient(newTorrent.infoHash)) {
Expand All @@ -312,7 +312,7 @@ export default class QBittorrent implements TorrentClient {
save_path: path,
isComplete: true,
autoTMM: false,
category: dataCategory,
category: linkingCategory,
}
: await this.getTorrentConfiguration(searchee);

Expand Down
10 changes: 5 additions & 5 deletions src/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,19 @@ function createCommandWithSharedOptions(name: string, description: string) {
.makeOptionMandatory(),
)
.option(
"--data-category <cat>",
"Category to assign torrents from data-based matching",
fallback(fileConfig.dataCategory, "cross-seed-data"),
"--linking-category <cat>",
"Torrent client category to set on linked torrents",
fallback(fileConfig.linkingCategory, "cross-seed-link"),
)
.option(
"--link-dir <dir>",
"Directory to output data-matched hardlinks to",
fileConfig.linkDir,
)
.option(
"--legacy-linking",
"--flat-linking",
"Use flat linking directory structure (without individual tracker folders)",
fallback(fileConfig.legacyLinking, false),
fallback(fileConfig.flatLinking, false),
)
.addOption(
new Option(
Expand Down
9 changes: 4 additions & 5 deletions src/config.template.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ module.exports = {
matchMode: "safe",

/**
* Defines what category torrents injected by data-based matching should
* use.
* Default is "cross-seed-data".
* Defines what qBittorrent or Deluge category to set on linked torrents
* Default is "cross-seed-link".
*/
dataCategory: undefined,
linkingCategory: "cross-seed-link",

/**
* If this is specified, cross-seed will create links to matched files in
Expand Down Expand Up @@ -150,7 +149,7 @@ module.exports = {
*
* Default: false.
*/
legacyLinking: false,
flatLinking: false,

/**
* Whether to skip recheck in qBittorrent or Deluge. Not supported in rTorrent/Transmission.
Expand Down
12 changes: 6 additions & 6 deletions src/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const ZodErrorMessages = {
recheckWarn:
"It is strongly recommended to not skip rechecking for risky or partial matching mode.",
windowsPath: `Your path is not formatted properly for Windows. Please use "\\\\" or "/" for directory separators.`,
qBitLegacyLinking:
"Using Automatic Torrent Management in qBittorrent without legacyLinking enabled can result in injection path failures.",
qBitFlatLinking:
"Using Automatic Torrent Management in qBittorrent without flatLinking enabled can result in injection path failures.",
needsLinkDir:
"You need to set a linkDir for risky or partial matching to work.",
};
Expand Down Expand Up @@ -115,10 +115,10 @@ export const VALIDATION_SCHEMA = z

.nullish(),
matchMode: z.nativeEnum(MatchMode),
dataCategory: z.string().nullish(),
linkingCategory: z.string().nullish(),
linkDir: z.string().transform(checkValidPathFormat).nullish(),
linkType: z.nativeEnum(LinkType),
legacyLinking: z
flatLinking: z
.boolean()
.nullish()
.transform((value) => (typeof value === "boolean" ? value : false)),
Expand Down Expand Up @@ -190,10 +190,10 @@ export const VALIDATION_SCHEMA = z
if (
config.action === Action.INJECT &&
config.qbittorrentUrl &&
!config.legacyLinking &&
!config.flatLinking &&
config.linkDir
) {
logger.warn(ZodErrorMessages.qBitLegacyLinking);
logger.warn(ZodErrorMessages.qBitFlatLinking);
}
return true;
})
Expand Down
4 changes: 2 additions & 2 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export interface FileConfig {
matchMode?: MatchMode;
linkDir?: string;
linkType?: string;
legacyLinking?: boolean;
flatLinking?: boolean;
skipRecheck?: boolean;
maxDataDepth?: number;
dataCategory?: string;
linkingCategory?: string;
torrentDir?: string;
torznab?: string[];
qbittorrentUrl?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export interface RuntimeConfig {
matchMode: MatchMode;
linkDir: string;
linkType: LinkType;
legacyLinking: boolean;
flatLinking: boolean;
skipRecheck: boolean;
maxDataDepth: number;
dataCategory: string;
linkingCategory: string;
torrentDir?: string;
outputDir: string;
includeEpisodes: boolean;
Expand Down

0 comments on commit 467e087

Please sign in to comment.