<<

NAME

ProductOpener::Paths - functions to get, check and initialize important directories

SYNOPSIS

VARIABLES

%BASE_DIRS

A hashmap containing references to base directories

$BASE_DIRS{LOGS}

Directory for logging

$BASE_DIRS{ORGS}

Directory containing sto of organizations

$BASE_DIRS{USERS}

Directory containing sto of users

$BASE_DIRS{PRODUCTS}

Directory containing sto of products

$BASE_DIRS{TAXONOMIES_SRC}

Directory containing txt taxonomies

$BASE_DIRS{CONF}

Directory containing configuration files

$BASE_DIRS{PRIVATE_DATA}

Directory for private data

$BASE_DIRS{LANG}

Directory with language files (.po). Normally linked to openfoodfacts-web

$BASE_DIRS{IMPORT_FILES}

files to import in producer platform

$BASE_DIRS{EXPORT_FILES}

files to export from producer platform to public platform

$BASE_DIRS{PRODUCTS_IMAGES}

product images is a big directory, normally a volume of its own

$BASE_DIRS{CACHE_TMP}

temporary files we manage locally

$BASE_DIRS{CACHE_NEW_IMAGES}

A directory to link newly updated images in order to apply processing (like OCR)

$BASE_DIRS{CACHE_DEBUG}

Temporary files for debugging purposes

$BASE_DIRS{CACHE_BUILD}

Files needed for various build phases - eg taxonomy and cached

$BASE_DIRS{DELETED_PRODUCTS}

Products deleted from the public platform

$BASE_DIRS{DELETED_PRODUCTS_IMAGES}

Products deleted from the public platform

$BASE_DIRS{DELETED_PRIVATE_PRODUCTS}

Products deleted from the producers platform

$BASE_DIRS{DELETED_IMAGES}

A directory to store deleted images (not accessible from web)

$BASE_DIRS{REVERTED_PRODUCTS}

A directory where we store revisions we reverted for some products

$BASE_DIRS{FILES_DEBUG}

A directory used to debug knowledge panels

$BASE_DIRS{PUBLIC_DATA}

The main public data directory where database dumps are published along with other assets

$BASE_DIRS{PUBLIC_DUMP}

$BASE_DIRS{PUBLIC_FILES}

$BASE_DIRS{PUBLIC_EXPORTS}

$BASE_DIRS{USERS_TRANSLATIONS}

Users contributed translations directory

$BASE_DIRS{SFTP_HOME}

sftp home directory, only for producers platform

FUNCTIONS

products_dir($server_name)

products directory for a foreign server

Arguments

$server_name - off/obf/opf/opff…

Return

String of path to base directory containing products sto

products_images_dir($server_name)

products images directory for a foreign server

Arguments

$server_name - off/obf/opf/opff…

Return

String of path to base directory containing products images

get_file_for_taxonomy( $tagtype )

Taxonomy .txt source files are stored in the /taxonomies directory.

Some Product Opener flavors (Open Food Facts, Open Beauty Facts etc.) can have different taxonomies for the same tag type. e.g. OFF and OBF can have different taxonomies for categories and ingredients.

Other categories like countries and languages are common to all flavors.

Taxonomies specific to a flavor are stored in /taxonomies/[product type]

e.g. OFF ingredients are in /taxonomies/food/ingredients.txt and OBF ingredients are in /taxonomies/beauty/ingredients.txt

get_path_for_taxonomy( $tagtype, $product_type )

full path for taxonomy file

base_paths()

Return the list of base paths as a hashmap

check_missing_dirs()

Check main directories, needed for the project to run, exists

Return

A ref to a list of missing paths

ensure_dir_created($path, $mode=oct(755))

Ensure a multiple path is created but die if a fundamental path is missing

ensure_dir_created_or_die($path, $mode=0755)

Ensure a multiple path is created but die if a fundamental path is missing

base_paths_loading_script()

Return a sh script to define environment variables

You can then use it in a script by running:

. <(perl -e 'use ProductOpener::Paths qw/:all/; print base_paths_loading_script()')

<<