Big rollup release — comprehensive audit + fixes across the codebase (26 commits since 8.23). Focus on long-standing correctness, security and login reliability.
What's fixed
Login & MEGA API
- Adds
&v=3+&ak=+&lang=to every API request, matching the official MEGA SDK / MEGAcmd. Without&ak=, MEGA's load balancer 402-throttles aggressively — this was the underlying cause of #614 ("argument 'content' is null", open since 2023) and the recurring "account works in megacmd, then MegaBasterd starts working" reports. - RAW_REQUEST now retries on HTTP 402 / 500 / 503, surfaces a real
MegaAPIExceptionon retry exhaustion instead of returningnull(which used to NPE every caller). _seqnois now atomic (was racy across concurrent workers sharing one MegaAPI).- Login uses
SecureRandomfor the initial sequence number.
Crypto / integrity
VERIFY_CBC_MACis now ON by default and corrupted output is deleted on mismatch instead of being left on disk with a 100% UI status. Should close the "random video corruption" / "decryption broken" class of reports (#740, #672, #746).- AES at-rest blobs (sessions, password_aes, user_hash) now use a per-blob random IV with a magic-prefix format. Backwards compatible — pre-8.24 blobs still decrypt; new writes use the new format. No DB migration needed.
SecureRandom(notjava.util.Random) for every AES file key, CTR nonce, salt and request ID.- ChunkUploader chunk-MAC race fixed — could silently corrupt uploads ("MEGA API Error -2").
- MegaProxyServer now binds to loopback only; constant-time auth compare; redacted Proxy-Authorization in logs.
sid=/uh=/mfa=redaction in error logs so bug reports don't leak session tokens.
Stuck / "joining file chunks never stops" / .McTemp persists
- Removed the global static
ChunkWriterManager.JOIN_CHUNKS_LOCK(one bad path could deadlock every concurrent download app-wide). _output_streamis now closed even on exception paths (Windows used to lock the .McTemp on a mid-flight failure).- Closes #706, #728, #684, #433, #557, #586, #570.
Single-instance / startup
- File-lock based single-instance detection (previously a foreign process holding port 1338 made MegaBasterd silently exit on startup — #717).
- Migration typo fixed in
_check_old_version: every user since who-knows-when was losing settings on upgrade becauseold_version_minorwas never assigned. parseInt(selectSettingValue(...))is wrapped — a single corrupt setting no longer aborts startup with a stack trace.- pom.xml source/target bumped from 1.8 → 11 (the code already required Java 11).
Resources / leaks
- HttpURLConnection error streams drained before disconnect (was 0 occurrences across the codebase → socket churn on every 509/403/429).
- Keep-alive preserved on API success path.
SqliteSingletonrewrite — previously everytry(Connection conn = ...getConn())closed the cached singleton on each call, defeating the cache entirely. Should reduce SQLITE_READONLY-class flakes.- Try-with-resources on
ChunkUploaderRAF,FileMergerDialogparts,Download._output_stream,MegaAPI.uploadThumbnails. - Thumbnailer/Xuggler native cleanup on every exit path.
deleteOnExit+ startup sweep for orphan thumbnail temp files. - MegaProxyServer bounded daemon
ExecutorService(was rawnew Thread().start()per connection, no cap). ThrottledInputStream/ThrottledOutputStreamfinally overrideclose()(the decorator was broken — caller closing the wrapper closed nothing).
Concurrency
volatileon every cross-thread-mutated field (_file_size,_chunkmanager,_paused_workers,_last_chunk_id_dispatched, ...).getChunkworkers()returns a defensive copy (was throwingConcurrentModificationExceptionon iteration).paused_workers >=instead of==(off-by-one left the UI stuck on "RESUME DOWNLOAD" forever).secureWaitacross 10 classes now restoresThread.interrupt()status (was inert pre-fix)._total_size/_total_progressdrift on restart fixed (global progress bar used to drift over hours of use).BoundedExecutorreleases the permit on anyThrowable(was only onRejectedExecutionException).
UI / EDT
SpeedMeterbatched into a singleinvokeLaterper tick (was per-rowinvokeAndWait× N transfers off-EDT).- Off-EDT Swing setters across the codebase wrapped via
GUIRun/GUIRunAndWait. JOptionPane.show*callsites wrapped (was pumping the modal event loop from worker threads)._updateViewonly revalidates the affected scroll panel, not the full frame.- Reorder uses
setComponentZOrderinstead of remove+add per row. FolderLinkDialogprogress is throttled (was 10000+ invokeLater for a 10k-file folder).- New opt-in
STRICT_EDT_CHECKS(-Dmegabasterd.strict_edt=true) catches future off-EDT regressions.
Charsets / locale / Windows paths
- Explicit
StandardCharsets.UTF_8for folder cache write/read (was platform default, corrupted non-ASCII filenames on cp1252 Windows — #710 / #744 class). Locale.ROOTontoLowerCaseused for OS detection (Turkish-I bug).cleanFilenamehandles Windows reserved names (CON,PRN,AUX,NUL,COM1-9,LPT1-9) and caps at 250 chars.Locale.ROOTonSimpleDateFormatfor the upload log timestamps.
Logging
- The "Debug file" option actually works now. Previously it only redirected
System.out/System.err;java.util.logginghad cached the original stderr before the redirect, so everyLOG.log(...)call was dropped. Now aFileHandleris installed on the root logger pointing at the same file. MegaAPI/MegaCrypterAPIerrors include the account email + redacted URL + full stack trace.- All
ex.printStackTrace()replaced withLogger.log(..., ex).
Misc user-reported fixes
- #719 same-name downloads —
insertDownloadretries with random filename suffix onUNIQUE(path, filename). - #715 clipboard monitor re-adding duplicates —
LinkGrabberDialogdedupes against existing entries. - #699 deleted download keeps coming back on startup —
Download.close()/DownloadManager.remove()always delete from DB, not only when_provision_ok. - #434 false "all transfers complete" tray notification —
_genStatusnow counts both preprocess queues. - #645 account import file errors — skip malformed lines (was NPE'ing the save loop).
- Folder cache has a 24h TTL (was stale forever).
formatBytes(null)NPE guard.- HTTP
Range: bytes=-N(suffix-range) support in streaming server. - Float→double in
calculateLastWrittenChunk(resume of >16 MiB files could rewind a chunk). MegaProxyServer.Handler.readLinehas SO_TIMEOUT (slowloris cap).
Compatibility
- Existing DB (
megabasterd.db) is read fine. Sessions / accounts / downloads / settings carry over. - No master password re-entry needed.
- New format AES blobs are written going forward; old blobs continue to decrypt with the legacy zero-IV path.
Known gaps
- #746 partially addressed (Bugs #1 + #3 closed; SmartProxy/VPN runtime config-reload still needed for #2 + #4).
- #736 (upload to root creates folder) diagnosed but not patched — pending UX decision on the share-link wrapping folder.
- #737 (alias
#S25fails) not reproducible from code analysis; likely MEGA-side timing.
Build
JDK 11+ required. Jar is MegaBasterd_8.24.jar below.
java -jar MegaBasterd_8.24.jar
Portable bundles will follow when the maintainer has the build scripts handy.
Full commit list: v8.23...v8.24