Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Checking for Orphaned Files - Uncaught Exception #275

Closed
pax0707 opened this issue Apr 25, 2023 · 10 comments · Fixed by #301
Closed

[Bug]: Checking for Orphaned Files - Uncaught Exception #275

pax0707 opened this issue Apr 25, 2023 · 10 comments · Fixed by #301
Assignees
Labels
bug Something isn't working status:added-to-develop Feature Request or Bug Fix is in Develop

Comments

@pax0707
Copy link

pax0707 commented Apr 25, 2023

Describe the Bug

Orphened files don't get moved, errors out with an uncaught exception.

Config

# This is an example configuration file that documents all the options.
# It will need to be modified for your specific use case.
# Please refer to the link below for more details on how to set up the configuration file
# https://github.com/StuffAnThings/qbit_manage/wiki/Config-Setup

commands:
  # The commands defined below will IGNORE any commands used in command line and docker env variables.
  dry_run: false
  cross_seed: true
  recheck: true
  cat_update: false
  tag_update: true
  rem_unregistered: true
  tag_tracker_error: true
  rem_orphaned: true
  tag_nohardlinks: true
  skip_cleanup: false

qbt:
  # qBittorrent parameters
  host: localhost:9098
  user: xxxx
  pass: xxxx

settings:
  force_auto_tmm: false  # Will force qBittorrent to enable Automatic Torrent Management for each torrent.
  tracker_error_tag: ===ERROR===  # Will set the tag of any torrents that do not have a working tracker.
  ignoreTags_OnUpdate: # When running tag-update function, it will update torrent tags for a given torrent even if the torrent has one or more of the tags defined here.
  - ===NOHL===
  - ===ERROR===
  - cross-seed
  nohardlinks_tag: ===NOHL===
directory:
  # Do not remove these
  # Cross-seed var: </your/path/here/>  # Output directory of cross-seed
  # root_dir var: </your/path/here/>  # Root downloads directory used to check for orphaned files, noHL, and RecycleBin.
  # <OPTIONAL> remote_dir var: </your/path/here/>  # Path of docker host mapping of root_dir.
  # Must be set if you're running qbit_manage locally and qBittorrent/cross_seed is in a docker
  # <OPTIONAL> recycle_bin var: </your/path/here/>   # Path of the RecycleBin folder. Default location is set to remote_dir/.RecycleBin
  # <OPTIONAL> torrents_dir var: </your/path/here/>  # Path of the your qbittorrent torrents directory. Required for `save_torrents` attribute in recyclebin

  cross_seed: D:\QBT\Torrents\CS\cross-seed
  root_dir: D:\QBT\Done\
  remote_dir: D:\QBT\Done\
  recycle_bin: D:\QBT\Recycle\
  torrents_dir: C:\Users\pax07\AppData\Local\qBittorrent\BT_backup\
  orphaned_dir: D:\QBT\Orphaned\
cat:
  SERIES/SONARR: D:\QBT\Done\SERIES\SONARR\
  SERIES/MEDUSA: D:\QBT\Done\SERIES\Medusa\
  SERIES/101: D:\QBT\Done\SERIES\101\
  MOVIES/RADARR: D:\QBT\Done\MOVIES\RADARR\
  MOVIES/PTP: D:\QBT\Done\MOVIES\PTP\
  SITE/AlphaRatio: D:\QBT\Done\SITE\AlphaRatio\
  SITE/Keep Alive: D:\QBT\Done\SITE\Keep Alive\
  SERIES/B5: D:\QBT\Done\SERIES\B5\
  SITE: D:\QBT\Done\SITE\
  SITE/The Geeks: D:\QBT\Done\SITE\The Geeks\
  Redacted: D:\QBT\Done\SITE\Redacted\
  Done: D:\QBT\Done\
  Sonarr: D:\QBT\Done\SERIES\Sonarr\
  MOVIES: D:\QBT\Done\MOVIES\
  SEED: D:\QBT\Torrents\Done\NGS\SEED\
tracker:
  # Tag Parameters
  # <Tracker URL Keyword>:    # <MANDATORY> This is the keyword in the tracker url
  # <MANDATORY> Set tag name. Can be a list of tags or a single tag
  #   tag: <Tag Name>
  # <OPTIONAL> Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading. -2 means the global limit should be used, -1 means no limit.
  #   max_ratio: 5.0
  # <OPTIONAL> Will set the torrent Maximum seeding time (min) until torrent is stopped from seeding. -2 means the global limit should be used, -1 means no limit.
  #   max_seeding_time: 129600
  # <OPTIONAL> Will ensure that noHL torrents from this tracker are not deleted by cleanup variable if torrent has not yet met the minimum seeding time (min).
  #   min_seeding_time: 2000
  # <OPTIONAL> Will limit the upload speed KiB/s (KiloBytes/second) (-1 sets the limit to infinity)
  #   limit_upload_speed: 150
  # <OPTIONAL> Set this to the notifiarr react name. This is used to add indexer reactions to the notifications sent by Notifiarr
  #   notifiarr: <notifiarr indexer>
  animebytes.tv:
    tag: AnimeBytes
    max_ratio: 3
  beyond-hd:
    tag: Beyond-HD
    max_ratio: -1
  gazellegames:
    tag: GazelleGames
    max_ratio: -1
  landof.tv:
    tag: BroadcasTheNet
    max_ratio: -1
  myanonamouse:
    tag: MyAnonamouse
    max_ratio: -1
  passthepopcorn:
    tag: PassThePopcorn
    max_ratio: -1
  tleechreload:
    tag: TorrentLeech
    max_ratio: 3
  torrentdb:
    tag: TorrentDB
    vmax_ratio: 3
  torrentleech:
    tag: TorrentLeech
    max_ratio: 3
  hdbits:
    tag: HDBits
    max_ratio: 5
  morethantv:
    tag: MoreThanTV
    max_ratio: 3
  filelist.io:
    tag: FileList
    max_ratio: 5
  stackoverflow.tech:
    tag: IPTorrents
    max_ratio: 3
  alpharatio.cc:
    tag: AlphaRatio
    max_ratio: 3
  torrenthr.org:
    tag: TorrentHR
    max_ratio: 5
  opsfet.ch:
    tag: Orpheus
    max_ratio: -1
  hd-space.pw:
    tag: HD-Space
    max_ratio: 3
  bit-hdtv.com:
    tag: BIT-HDTV
    max_ratio: 3
  bibliotik.me:
    tag: Bibliotik
    max_ratio: -1
  music-vid.com:
    tag: MusicVids
    max_ratio: -1
  flacsfor.me:
    tag: Redacted
    max_ratio: -1
  thegeeks.click:
    tag: TheGeeks
    max_ratio: 5
  immortalseed.me:
    tag: Imortalseed
    max_ratio: 3
  other:
    tag: ===OTHER===
    max_ratio: 3
nohardlinks:
  MOVIES/RADARR:
    exclude_tags:
    cleanup: false
  MOVIES/PTP:
    exclude_tags:
    cleanup: false
  SERIES/SONARR:
    exclude_tags:
    cleanup: false
recyclebin:
  # Recycle Bin method of deletion will move files into the recycle bin (Located in /root_dir/.RecycleBin) instead of directly deleting them in qbit
  # By default the Recycle Bin will be emptied on every run of the qbit_manage script if empty_after_x_days is defined.
  enabled: false
  # <OPTIONAL> empty_after_x_days var:
  # Will automatically remove all files and folders in recycle bin after x days. (Checks every script run)
  # If this variable is not defined it, the RecycleBin will never be emptied.
  # WARNING: Setting this variable to 0 will delete all files immediately upon script run!
  empty_after_x_days: 60
  # <OPTIONAL> save_torrents var:
  # If this option is set to true you MUST fill out the torrents_dir in the directory attribute.
  # This will save a copy of your .torrent and .fastresume file in the recycle bin before deleting it from qbittorrent
  save_torrents: true
  # <OPTIONAL> split_by_category var:
  # This will split the recycle bin folder by the save path defined in the `cat` attribute
  # and add the base folder name of the recycle bin that was defined in the `recycle_bin` sub-attribute under directory.
  split_by_category: false

orphaned:
  # Orphaned files are those in the root_dir download directory that are not referenced by any active torrents.
  # Will automatically remove all files and folders in orphaned data after x days. (Checks every script run)
  # If this variable is not defined it, the orphaned data will never be emptied.
  # WARNING: Setting this variable to 0 will delete all files immediately upon script run!
  empty_after_x_days: 60
  # File patterns that will not be considered orphaned files. Handy for generated files that aren't part of the torrent but belong with the torrent's files
  exclude_patterns:
  - '**/.DS_Store'
  - '**/Thumbs.db'
  - '**/@eaDir'
  - /data/torrents/temp/**
  - '**/*.!qB'

#apprise:
  # Apprise integration with webhooks
  # Leave Empty/Blank to disable
  # Mandatory to fill out the url of your apprise API endpoint
  #api_url:
  # Mandatory to fill out the notification url/urls based on the notification services provided by apprise. https://github.com/caronc/apprise/wiki
  #notify_url:

#notifiarr:
  # Notifiarr integration with webhooks
  # Leave Empty/Blank to disable
  # Mandatory to fill out API Key
  #apikey:
  # <OPTIONAL> Set to a unique value (could be your username on notifiarr for example)
  #instance:

webhooks:
  error:
  run_start:
  run_end:
  function:
    cross_seed:
    recheck:
    cat_update:
    tag_update:
    rem_unregistered:
    tag_tracker_error:
    rem_orphaned:
    tag_nohardlinks:
    cleanup_dirs:

bhd:
  # BHD Integration used for checking unregistered torrents
  apikey: xxxx

Logs

https://gist.github.com/pax0707/bd16dde738ce74fbd2179c9cab2a65b5

Screenshots

No response

Installation

Local

Version Number

3.6.2

What branch are you on?

master

@pax0707 pax0707 added the bug Something isn't working label Apr 25, 2023
@fIows
Copy link

fIows commented May 12, 2023

Did you ever get it to work? I am having the same issue and using windows as well.

@pax0707
Copy link
Author

pax0707 commented May 12, 2023

Nope.

I disabled orphaned in the current version and call a separate older version to do just the orphaned handling.

@fIows
Copy link

fIows commented May 12, 2023

Nope.

I disabled orphaned in the current version and call a separate older version to do just the orphaned handling.

What version works fine for you?

@pax0707
Copy link
Author

pax0707 commented May 12, 2023

What version works fine for you?

One of the versions prior to 3.5.
At work so can't check.

@buthed010203
Copy link
Contributor

I believe that the issue should be fixed in #293 but I haven't actually tested it on windows so it may not actually fix anything

@bobokun bobokun added the status:added-to-develop Feature Request or Bug Fix is in Develop label May 20, 2023
@bobokun
Copy link
Collaborator

bobokun commented May 20, 2023

@flows, @pax0707 , can you please test using the latest develop branch to see if you still have this issue?

@pax0707
Copy link
Author

pax0707 commented May 20, 2023

Getting this:

| No torrents to tag with no hardlinks.                                                              |
| Uncaught Exception                                                                                 |
Traceback (most recent call last):
  File "C:\PAX\qbit_manage\qbit_manage.py", line 551, in <module>
    start_loop()
  File "C:\PAX\qbit_manage\qbit_manage.py", line 322, in start_loop
    start()
  File "C:\PAX\qbit_manage\qbit_manage.py", line 429, in start
    stats["orphaned"] += RemoveOrphaned(qbit_manager).stats
  File "C:\PAX\qbit_manage\modules\core\remove_orphaned.py", line 23, in __init__
    self.pool = Pool(processes=max(cpu_count() - 1, 1), initializer=init_pool, initargs=(self.config,))
  File "C:\Program Files\Python38\lib\multiprocessing\context.py", line 119, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild,
  File "C:\Program Files\Python38\lib\multiprocessing\pool.py", line 212, in __init__
    self._repopulate_pool()
  File "C:\Program Files\Python38\lib\multiprocessing\pool.py", line 303, in _repopulate_pool
    return self._repopulate_pool_static(self._ctx, self.Process,
  File "C:\Program Files\Python38\lib\multiprocessing\pool.py", line 326, in _repopulate_pool_static
    w.start()
  File "C:\Program Files\Python38\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Program Files\Python38\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Program Files\Python38\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Program Files\Python38\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'Request._session.<locals>.QbittorrentSession'
Press any key to continue . . . Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files\Python38\lib\multiprocessing\spawn.py", line 102, in spawn_main
    source_process = _winapi.OpenProcess(
OSError: [WinError 87] The parameter is incorrect

@buthed010203
Copy link
Contributor

I sure do love python

bobokun added a commit that referenced this issue May 22, 2023
@bobokun
Copy link
Collaborator

bobokun commented May 22, 2023

@pax0707 can you please test again?

bobokun added a commit that referenced this issue May 22, 2023
@pax0707
Copy link
Author

pax0707 commented May 22, 2023

@bobokun working now!

 No torrents to tag with no hardlinks.                                                              |
|=================================== Checking for Orphaned Files ====================================|
| Locating orphan files                                                                              |
| Processing orphan exclude patterns                                                                 |
| 5 Orphaned files found                                                                             |
| D:\QBT\Done\MOVIES\RADARR\Scream.2.1997.2160p.UHD.BluRay.x265-B0MBARDiERS\scream.2.1997.2160p.uhd.bluray.x265-b0mbardiers.mkv |
| D:\QBT\Done\SERIES\SONARR\Big.Beasts.S01E07.1080p.WEB.H264-GGEZ\big.beasts.s01e07.1080p.web.h264-ggez\Big.Beasts.S01E07.1080p.WEB.H264-GGEZ\big.beasts.s01e07.1080p.web.h264-ggez.mkv |
| D:\QBT\Done\SERIES\SONARR\Big.Beasts.S01E08.1080p.WEB.H264-GLHF\big.beasts.s01e08.1080p.web.h264-glhf\Big.Beasts.S01E08.1080p.WEB.H264-GLHF\big.beasts.s01e08.1080p.web.h264-glhf.mkv |
| D:\QBT\Done\SERIES\SONARR\Digman.S01E08.1080p.WEB.h264-BAE\digman.s01e08.1080p.web.h264-bae\Digman.S01E08.1080p.WEB.h264-BAE\Digman.S01E08.1080p.WEB.h264-BAE.mkv |
| D:\QBT\Done\SERIES\SONARR\Yellowjackets.S02E07.1080p.WEB.H264-CAKES\yellowjackets.s02e07.1080p.web.h264-cakes\Yellowjackets.S02E07.1080p.WEB.H264-CAKES\yellowjackets.s02e07.1080p.web.h264-cakes.mkv |
| Moving 5 Orphaned files to D:\QBT\Orphaned\                                                        |
| Removing newly empty directories                                                                   |
|====================================================================================================|

@bobokun bobokun mentioned this issue May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status:added-to-develop Feature Request or Bug Fix is in Develop
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants