File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
patches/src/main/kotlin/app/revanced/patches
youtube/layout/branding/header Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,17 @@ internal fun baseCustomBrandingPatch(
115115 )
116116 } else {
117117 val iconPathFile = File (iconPathTrimmed)
118+ if (! iconPathFile.exists()) {
119+ throw PatchException (" The custom icon path cannot be found: " +
120+ iconPathFile.absolutePath
121+ )
122+ }
123+
124+ if (! iconPathFile.isDirectory) {
125+ throw PatchException (" The custom icon path must be a directory: "
126+ + iconPathFile.absolutePath)
127+ }
128+
118129 val resourceDirectory = get(" res" )
119130 var replacedResources = false
120131
@@ -155,7 +166,8 @@ internal fun baseCustomBrandingPatch(
155166 }
156167
157168 if (! replacedResources) {
158- throw PatchException (" Could not find any replacement images in patch option path: $iconPathTrimmed " )
169+ throw PatchException (" Could not find any replacement images in " +
170+ " patch option path: " + iconPathFile.absolutePath)
159171 }
160172 }
161173
Original file line number Diff line number Diff line change @@ -136,8 +136,21 @@ val changeHeaderPatch = resourcePatch(
136136 )
137137
138138 if (custom != null ) {
139- val sourceFolders = File (custom!! ).listFiles { file -> file.isDirectory }
140- ? : throw PatchException (" The provided path is not a directory: $custom " )
139+ val customFile = File (custom!! )
140+ if (! customFile.exists()) {
141+ throw PatchException (" The custom icon path cannot be found: " +
142+ customFile.absolutePath
143+ )
144+ }
145+
146+ if (! customFile.isDirectory) {
147+ throw PatchException (" The custom icon path must be a directory: "
148+ + customFile.absolutePath)
149+ }
150+
151+ val sourceFolders = customFile.listFiles { file -> file.isDirectory }
152+ ? : throw PatchException (" The custom icon path contains no subdirectories: " +
153+ customFile.absolutePath)
141154
142155 val customResourceFileNames = getLightDarkFileNames(CUSTOM_HEADER_RESOURCE_NAME )
143156
@@ -166,7 +179,8 @@ val changeHeaderPatch = resourcePatch(
166179 }
167180
168181 if (! copiedFiles) {
169- throw PatchException (" No custom header images found in the provided path: $custom " )
182+ throw PatchException (" No custom header images found in " +
183+ " the provided path: ${customFile.absolutePath} " )
170184 }
171185 }
172186
You can’t perform that action at this time.
0 commit comments