Skip to content

Commit

Permalink
Merge pull request #3535 from osmandapp/nmv_remove_logs
Browse files Browse the repository at this point in the history
Disable error logs when checking resource availability
  • Loading branch information
alex-osm committed Mar 28, 2024
2 parents 02152f7 + 250f566 commit 25233cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Sources/Core/CoreResourcesFromBundleProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
class CoreResourcesFromBundleProvider : public OsmAnd::ICoreResourcesProvider
{
private:
static NSString* getResourcePath(const QString& name);
static NSString* getResourcePath(const QString& name, const bool logErrors);
static NSString* getResourcePath(const QString& name,
const float displayDensityFactor);
const float displayDensityFactor,
const bool logErrors);
protected:
public:
CoreResourcesFromBundleProvider();
Expand Down
25 changes: 15 additions & 10 deletions Sources/Core/CoreResourcesFromBundleProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
const float displayDensityFactor,
bool* ok /* = nullptr*/) const
{
NSString* resourcePath = getResourcePath(name, displayDensityFactor);
NSString* resourcePath = getResourcePath(name, displayDensityFactor, true);

if (!resourcePath)
{
Expand All @@ -55,7 +55,7 @@
QByteArray CoreResourcesFromBundleProvider::getResource(const QString& name,
bool* ok /* = nullptr*/) const
{
NSString* resourcePath = getResourcePath(name);
NSString* resourcePath = getResourcePath(name, true);

if (!resourcePath)
{
Expand All @@ -82,19 +82,19 @@
bool CoreResourcesFromBundleProvider::containsResource(const QString& name,
const float displayDensityFactor) const
{
NSString* resourcePath = getResourcePath(name, displayDensityFactor);
NSString* resourcePath = getResourcePath(name, displayDensityFactor, false);

return ([[NSFileManager defaultManager] fileExistsAtPath:resourcePath] == YES);
}

bool CoreResourcesFromBundleProvider::containsResource(const QString& name) const
{
NSString* resourcePath = getResourcePath(name);
NSString* resourcePath = getResourcePath(name, false);

return ([[NSFileManager defaultManager] fileExistsAtPath:resourcePath] == YES);
}

NSString* CoreResourcesFromBundleProvider::getResourcePath(const QString& name)
NSString* CoreResourcesFromBundleProvider::getResourcePath(const QString& name, const bool logErrors)
{
NSString* resourceName = nil;
NSString* resourceType = nil;
Expand Down Expand Up @@ -174,7 +174,8 @@
}
else
{
OALog(@"Unrecognized resource name '%@'", name.toNSString());
if (logErrors)
OALog(@"Unrecognized resource name '%@'", name.toNSString());
return nil;
}

Expand All @@ -183,15 +184,17 @@
inDirectory:resourceDir];
if (!resourcePath)
{
OALog(@"Failed to locate '%@', but it have to be present", name.toNSString());
if (logErrors)
OALog(@"Failed to locate '%@', but it have to be present", name.toNSString());
return nil;
}

return resourcePath;
}

NSString* CoreResourcesFromBundleProvider::getResourcePath(const QString& name,
const float displayDensityFactor)
const float displayDensityFactor,
const bool logErrors)
{
NSString* resourceName = nil;
NSString* resourceType = nil;
Expand Down Expand Up @@ -259,7 +262,8 @@
}
else
{
OALog(@"Unrecognized resource name '%@'", name.toNSString());
if (logErrors)
OALog(@"Unrecognized resource name '%@'", name.toNSString());
return nil;
}

Expand All @@ -268,7 +272,8 @@
inDirectory:resourceDir];
if (!resourcePath)
{
OALog(@"Failed to locate '%@', but it have to be present", name.toNSString());
if (logErrors)
OALog(@"Failed to locate '%@', but it have to be present", name.toNSString());
return nil;
}

Expand Down

0 comments on commit 25233cf

Please sign in to comment.